当前位置:网站首页>matlab习题 —— 矩阵的常规运算
matlab习题 —— 矩阵的常规运算
2022-06-28 02:18:00 【繁依Fanyi】
matlab系列文章:目录

一、题目
设矩阵
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) 提取矩阵 A A A 的第一、三行,矩阵 B B B 的第一、三列;交换矩阵 A A A 的第一、 二行,矩阵 B B B 的第一、二列;
- (2) 删去矩阵 A A A 的第二行,删去矩阵 B B B 的第二列;
- (3) 计算 ∣ A ∣ |A| ∣A∣, ∣ B ∣ |B| ∣B∣, A − 1 A^{-1} A−1, B − 1 B^{-1} B−1, A A A、 B B B 的特征值与特征向量, A A A、 B B B 的转置矩阵,将矩阵 A A A 上下颠倒、矩阵 B B B 左右颠倒,计算矩阵 A A A 的每行的最大值与均值、每列的最小值,输出矩阵 B B B 最大元素与最小元素所在的行与列位置、合并矩阵 A A A 和 B B B;
- (4) 计算 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。
二、解答
① 创建两个矩阵:
>> A = [4 -2 2;-3 0 5;1 5 3] %创建矩阵A
A =
4 -2 2
-3 0 5
1 5 3
>> B = [1 3 4;-2 0 3;2 -1 1] %创建矩阵B
B =
1 3 4
-2 0 3
2 -1 1
题一
1. 提取矩阵A的一、三行
>> A([1 3],:)
ans =
4 -2 2
1 5 3
2. 提取矩阵B的一、三列
>> B(:,[1 3])
ans =
1 4
-2 3
2 1
3. 交换矩阵 A 的第一、 二行
>> A([1 2],:) = A([2 1],:)
A =
-3 0 5
4 -2 2
1 5 3
4. 交换矩阵 B 的第一、二列
>> B(:,[1 2]) = B(:,[2 1])
B =
3 1 4
0 -2 3
-1 2 1
题二
1. 删去矩阵 A 的第二行
>> A([2],:) = []
A =
-3 0 5
1 5 3
2. 删去矩阵 B 的第二列
>> B(:,[2]) = []
B =
3 4
0 3
-1 1
题三
1. 计算 ∣ A ∣ |A| ∣A∣, ∣ B ∣ |B| ∣B∣
>> det(A)
ans =
-158
>> det(B)
ans =
35
2. 计算 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. 计算 A A A、 B B B 的特征值与特征向量
>> [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 =
列 1 至 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
列 3
-0.0719 - 0.5666i
-0.7330 + 0.0000i
0.1776 + 0.3240i
y2 =
列 1 至 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
列 3
0.0000 + 0.0000i
0.0000 + 0.0000i
-0.9230 - 2.8720i
4. 求 A A A、 B B B 的转置矩阵
>> A.'
ans =
4 -3 1
-2 0 5
2 5 3
>> B.'
ans =
1 -2 2
3 0 -1
4 3 1
5. 将矩阵 A A A 上下颠倒、矩阵 B B B 左右颠倒
>> 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. 计算矩阵 A A A 的每行的最大值与均值、每列的最小值
① 计算 A A A 的每行的最大值
>> max(A,[],2)
ans =
4
5
5
② 计算 A A A 的每行的均值
>> mean(A,2)
ans =
1.3333
0.6667
3.0000
③ 计算 A A A 的每列的最小值
>> min(A,[],1)
ans =
-3 -2 2
7. 输出矩阵 B B B 最大元素与最小元素所在的行与列位置
① 输出矩阵 B B B 最大元素所在的行与列位置
>> [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]
① 输出矩阵 B B B 最小元素所在的行与列位置
>> [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. 合并矩阵 A A A 和 B B B
>> [A,B]
ans =
4 -2 2 1 3 4
-3 0 5 -2 0 3
1 5 3 2 -1 1
题四
1. 计算 A + B A+B A+B
>> A+B
ans =
5 1 6
-5 0 8
3 4 4
2. 计算 A − B A-B A−B
>> A-B
ans =
3 -5 -2
-1 0 2
-1 6 2
3. 计算 A B AB AB
>> A*B
ans =
12 10 12
7 -14 -7
-3 0 22
4. 计算 B A BA BA
>> B*A
ans =
-1 18 29
-5 19 5
12 1 2
5. 计算 A 2 A^2 A2
>> A*A
ans =
24 2 4
-7 31 9
-8 13 36
6. 计算 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. 计算 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

边栏推荐
- Tencent games released more than 40 products and projects, including 12 new games
- TensorRT 模型推理优化实现
- AgilePLM异常解决-Session篇
- PHP 代码 微信、公众号、企业微信 发送表情符号 [U+1F449]
- Gateway microservice routing failed to load microservice static resources
- 分布式事务TCC浅析
- [issue 21] face to face experience of golang engineer recruited by Zhihu Society
- [postgraduate] bit by bit
- 嵌入式DSP音频开发
- 【活动早知道】LiveVideoStack近期活动一览
猜你喜欢

Question bank and answers of special operation certificate for R1 quick opening pressure vessel operation in 2022

2022危险化学品经营单位安全管理人员特种作业证考试题库模拟考试平台操作

业内首个!可运行在移动设备端的视频画质主观体验MOS分评估模型!

2022年R1快开门式压力容器操作特种作业证考试题库及答案

Review the submission of small papers for 2022 spring semester courses

暴雨去哪儿?天气预报不准谁的锅?

测试要掌握的技术有哪些?软件测试必懂的数据库设计大全篇

2022安全员-C证考试题库模拟考试平台操作

TensorRT 模型推理优化实现

be fond of the new and tired of the old? Why do it companies prefer to spend 20K on recruiting rather than raise salaries to retain old employees
随机推荐
Heartless sword Chinese English bilingual poem 004 Sword
一位博士在华为的22年(干货满满)
Mysql database operation - stored procedure, view, transaction, index, database backup
Apache, IIS6, ii7 independent IP host shielding restricts IP access
Windows 2003 64 bit system PHP running error: 1% is not a valid Win32 Application
PPT制作小技巧
R1 Quick Open Pressure Vessel Operation Special Operation Certificate Examination Library and Answers in 2022
空闲中断无法清除
【小程序】使用font-awesome字体图标的解决文案(图文)
Ten reasons for system performance failure
Built in functions for MySQL database operations
apache、iis6、ii7独立ip主机屏蔽限制ip访问
R语言惩罚逻辑回归、线性判别分析LDA、广义加性模型GAM、多元自适应回归样条MARS、KNN、二次判别分析QDA、决策树、随机森林、支持向量机SVM分类优质劣质葡萄酒十折交叉验证和ROC可视化
Dataloader参数collate_fn的使用
Flask Foundation: template inheritance + static file configuration
[522. longest special sequence II]
Reading makes people quiet
Is your IOT security strong enough?
Tips for visiting the website: you are not authorized to view the recovery method of this page
Apache - about Apache