当前位置:网站首页>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

边栏推荐
- Basic flask: template rendering + template filtering + control statement
- 网上股票投资交流群安全吗?进群免费开户靠谱嘛?
- Why are so many people keen on big factories because of the great pressure and competition?
- R语言惩罚逻辑回归、线性判别分析LDA、广义加性模型GAM、多元自适应回归样条MARS、KNN、二次判别分析QDA、决策树、随机森林、支持向量机SVM分类优质劣质葡萄酒十折交叉验证和ROC可视化
- [iptables & ICMP] description of ICMP Protocol in iptables default policy
- What are the technologies to be mastered in the test? Database design for software testing
- Simple file transfer protocol TFTP
- Dataloader参数collate_fn的使用
- Apache——阿帕奇簡介
- 项目实战!手把手教你 Jmeter 性能测试
猜你喜欢

Single page application (SPA) hash route and historical API route
![Redis cluster setup [simple]](/img/20/9974a290f8c5d346e2b404b48b02e5.png)
Redis cluster setup [simple]

A16z:元宇宙解锁游戏基础设施中的新机遇

项目实战!手把手教你 Jmeter 性能测试

What are the technologies to be mastered in the test? Database design for software testing

Build your own website (17)

Opencv -- geometric space transformation (affine transformation and projection transformation)

为什么OpenCV计算的帧率是错误的?

腾讯游戏发布40多款产品与项目 其中12款为新游戏

微信小程序中生成二维码
随机推荐
建立自己的网站(17)
嵌入式DSP音频开发
Notepad++--列编辑模式--用法/实例
You got 8K in the 3-year function test, but were overtaken by the new tester. In fact, you are pretending to work hard
Relative path writing of files
How fiddle uses agents
Review the submission of small papers for 2022 spring semester courses
idea自动生成代码
剑指 Offer 47. 礼物的最大价值(DP)
空闲中断无法清除
QEMU monitor usage
Is it reliable to invest in the inter-bank certificate of deposit fund? Is the inter-bank certificate of deposit fund safe
RichView TRVStyle TextStyles
Why are so many people keen on big factories because of the great pressure and competition?
【522. 最长特殊序列 II】
__getitem__和__setitem__
Redis搭建集群【简单】
Artifact for converting pcap to JSON file: joy (installation)
分布式事务解决方案Seata-Golang浅析
目标检测|SSD原理与实现