当前位置:网站首页>Matlab exercises -- routine operation of matrix
Matlab exercises -- routine operation of matrix
2022-06-28 04:27:00 【Fanyi】
matlab Series articles : Catalog

List of articles
- One 、 subject
- Two 、 answer
- Topic 1
- Topic two
- Question three
- 1. Calculation ∣ A ∣ |A| ∣A∣, ∣ B ∣ |B| ∣B∣
- 2. Calculation A − 1 A^{-1} A−1、 B − 1 B^{-1} B−1
- 3. Calculation A A A、 B B B Eigenvalues and eigenvectors of
- 4. seek A A A、 B B B The transpose matrix of
- 5. The matrix A A A Upside down 、 matrix B B B Turn left and right
- 6. Calculation of matrix A A A The maximum and average values of each row of 、 The minimum value of each column
- 7. The output matrix B B B The row and column positions of the largest and smallest elements
- 8. Merge matrix A A A and B B B
- Question 4
One 、 subject
Let's set the matrix
A = ( 4 − 2 2 − 3 0 5 1 5 3 ) , B = ( 1 3 4 − 2 0 3 2 − 1 1 ) A= \begin{pmatrix} 4&-2&2\\ -3&0&5\\ 1&5&3 \end{pmatrix}, B= \begin{pmatrix} 1&3&4\\ -2&0&3\\ 2&-1&1 \end{pmatrix} A=⎝⎛4−31−205253⎠⎞,B=⎝⎛1−2230−1431⎠⎞
- (1) Extract matrix A A A First 、 Three elements , matrix B B B First 、 The three column ; Commutative matrix A A A First 、 Two lines , matrix B B B First 、 Two columns ;
- (2) Delete matrix A A A The second line of , Delete matrix B B B The second column of ;
- (3) Calculation ∣ A ∣ |A| ∣A∣, ∣ B ∣ |B| ∣B∣, A − 1 A^{-1} A−1, B − 1 B^{-1} B−1, A A A、 B B B Eigenvalues and eigenvectors of , A A A、 B B B The transpose matrix of , The matrix A A A Upside down 、 matrix B B B Turn left and right , Calculation of matrix A A A The maximum and average values of each row of 、 The minimum value of each column , The output matrix B B B The row and column positions of the largest and smallest elements 、 Merge matrix A A A and B B B;
- (4) Calculation A + B A+B A+B, A − B A-B A−B, A B AB AB, B A BA BA, A 2 A^2 A2, A ∗ B A^* B A∗B, A / B A/B A/B.
Two 、 answer
① Create two matrices :
>> A = [4 -2 2;-3 0 5;1 5 3] % Create a matrix A
A =
4 -2 2
-3 0 5
1 5 3
>> B = [1 3 4;-2 0 3;2 -1 1] % Create a matrix B
B =
1 3 4
-2 0 3
2 -1 1
Topic 1
1. Extract matrix A One 、 Three elements
>> A([1 3],:)
ans =
4 -2 2
1 5 3
2. Extract matrix B One 、 The three column
>> B(:,[1 3])
ans =
1 4
-2 3
2 1
3. Commutative matrix A First 、 Two lines
>> A([1 2],:) = A([2 1],:)
A =
-3 0 5
4 -2 2
1 5 3
4. Commutative matrix B First 、 Two columns
>> B(:,[1 2]) = B(:,[2 1])
B =
3 1 4
0 -2 3
-1 2 1
Topic two
1. Delete matrix A The second line of
>> A([2],:) = []
A =
-3 0 5
1 5 3
2. Delete matrix B The second column of
>> B(:,[2]) = []
B =
3 4
0 3
-1 1
Question three
1. Calculation ∣ A ∣ |A| ∣A∣, ∣ B ∣ |B| ∣B∣
>> det(A)
ans =
-158
>> det(B)
ans =
35
2. Calculation A − 1 A^{-1} A−1、 B − 1 B^{-1} B−1
>> inv(A)
ans =
0.1582 -0.1013 0.0633
-0.0886 -0.0633 0.1646
0.0949 0.1392 0.0380
>> inv(B)
ans =
0.0857 -0.2000 0.2571
0.2286 -0.2000 -0.3143
0.0571 0.2000 0.1714
3. Calculation A A A、 B B B Eigenvalues and eigenvectors of
>> [x1,y1] = eig(A)
x1 =
0.3055 0.8054 0.2410
0.7795 0.0974 0.5208
-0.5469 0.5847 0.8189
y1 =
-4.6842 0 0
0 5.2102 0
0 0 6.4740
>> [x2,y2] = eig(B)
x2 =
Column 1 to 2
0.8210 + 0.0000i -0.0719 + 0.5666i
0.0181 + 0.0000i -0.7330 + 0.0000i
0.5706 + 0.0000i 0.1776 - 0.3240i
Column 3
-0.0719 - 0.5666i
-0.7330 + 0.0000i
0.1776 + 0.3240i
y2 =
Column 1 to 2
3.8461 + 0.0000i 0.0000 + 0.0000i
0.0000 + 0.0000i -0.9230 + 2.8720i
0.0000 + 0.0000i 0.0000 + 0.0000i
Column 3
0.0000 + 0.0000i
0.0000 + 0.0000i
-0.9230 - 2.8720i
4. seek A A A、 B B B The transpose matrix of
>> A.'
ans =
4 -3 1
-2 0 5
2 5 3
>> B.'
ans =
1 -2 2
3 0 -1
4 3 1
5. The matrix A A A Upside down 、 matrix B B B Turn left and right
>> flipud(A)
ans =
1 5 3
-3 0 5
4 -2 2
>> fliplr(B)
ans =
4 3 1
3 0 -2
1 -1 2
6. Calculation of matrix A A A The maximum and average values of each row of 、 The minimum value of each column
① Calculation A A A The maximum value per line of
>> max(A,[],2)
ans =
4
5
5
② Calculation A A A Mean value per line of
>> mean(A,2)
ans =
1.3333
0.6667
3.0000
③ Calculation A A A The minimum value of each column of
>> min(A,[],1)
ans =
-3 -2 2
7. The output matrix B B B The row and column positions of the largest and smallest elements
① The output matrix B B B The row and column position of the largest element
>> [x,y] = find(B==max(max(B)))
x =
1
y =
3
>> for i = 1:length(x)
fprintf('[%d,%d]\n',x(i),y(i))
end
[1,3]
① The output matrix B B B The row and column position of the smallest element
>> [x,y] = find(B==min(min(B)))
x =
2
y =
1
>> for i = 1:length(x)
fprintf('[%d,%d]\n',x(i),y(i))
end
[2,1]
8. Merge matrix A A A and B B B
>> [A,B]
ans =
4 -2 2 1 3 4
-3 0 5 -2 0 3
1 5 3 2 -1 1
Question 4
1. Calculation A + B A+B A+B
>> A+B
ans =
5 1 6
-5 0 8
3 4 4
2. Calculation A − B A-B A−B
>> A-B
ans =
3 -5 -2
-1 0 2
-1 6 2
3. Calculation A B AB AB
>> A*B
ans =
12 10 12
7 -14 -7
-3 0 22
4. Calculation B A BA BA
>> B*A
ans =
-1 18 29
-5 19 5
12 1 2
5. Calculation A 2 A^2 A2
>> A*A
ans =
24 2 4
-7 31 9
-8 13 36
6. Calculation A ∗ B A^* B A∗B
>> inv(A)*det(A)*B
ans =
-77.0000 -65.0000 -62.0000
-58.0000 68.0000 60.0000
17.0000 -39.0000 -132.0000
7. Calculation A / B A/B A/B
>> A/B
ans =
0 0 2.0000
0.0286 1.6000 0.0857
1.4000 -0.6000 -0.8000

边栏推荐
- Live online source code, JS dynamic effect, sidebar scrolling fixed effect
- Go language learning tutorial (14)
- 从零到一,教你搭建「以文搜图」搜索服务(一)
- Multithreading and high concurrency V: detailed explanation of wait queue, executor and thread pool (key)
- Building a server monitoring platform with telegraf influxdb grafana
- Analyse complète annuelle du marché chinois de l'audio en 2022
- 单一职责原则
- Introduction to multi project development, basic design class library project use
- [MySQL] multi table connection query
- 2021 year end summary and 2022 outlook
猜你喜欢

Go language -select statement

云厂商为什么都在冲这个KPI?

猫狗队列的问题

从零到一,教你搭建「以文搜图」搜索服务(一)

Web APIs DOM event foundation dark horse programmer

Visualization of loss using tensorboard

Reading notes of top performance version 2 (II) -- CPU monitoring

2022年6月对自己近况的一次总结

How to write a software test report? Here comes the third party performance report template

With favorable policies, more than 20 provinces and cities have launched the yuanuniverse development plan
随机推荐
如何遍历collections.OrderedDict,服了又忘记items
视频爆炸时代,谁在支撑视频生态网高速运行?
Multithreading and high concurrency six: source code analysis of thread pool
抖音实战~取关博主
Live online source code, JS dynamic effect, sidebar scrolling fixed effect
设计一个有getMin功能的栈
Uncover the mystery of SSL and learn how to protect data with SSL
利用ELK 搭建日志分析系统(二)—— 部署安装
leetcode - 329. Longest increasing path in matrix
Establishment of SSH Framework (Part 2)
A summary of my recent situation in June 2022
La norme européenne en 597 - 1 pour les meubles est - elle la même que les deux normes en 597 - 2 pour les ignifuges?
RT-Thread 双向链表(学习笔记)
Introduction notes to machine learning
Multithreading and high concurrency V: detailed explanation of wait queue, executor and thread pool (key)
Component splitting practice
Array method
Annual comprehensive analysis of China's audio market in 2022
How to learn a programming language systematically| Dark horse programmer
Web APIs DOM event foundation dark horse programmer