matlab函数计算的一些简单例子2
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
MATLAB 作业二
1、请将下面给出的矩阵A 和B 输入到MATLAB 环境中,并将它们转换成符号矩阵。若某一
矩阵为数值矩阵,另以矩阵为符号矩阵,两矩阵相乘是符号矩阵还是数值矩阵。
57651653
5501232310014325462564206441211346,3
9636623
51521210760077410120172440773
473
78
124867217110
7
681
5A B ⎡⎤⎡⎤
⎢⎥⎢⎥⎢⎥⎢⎥⎢⎥
⎢⎥⎢⎥⎢
⎥==⎢⎥⎢⎥⎢⎥
⎢⎥⎢⎥⎢
⎥---⎢⎥⎢⎥⎢⎥⎢⎥--⎣⎦⎣
⎦
解:A 转换为符号矩阵;a=sym(A)
a=[5,7,6,5,1,6,5]
[2,3,1,0,0,1,4][6,4,2,0,6,4,4][3,9,6,3,6,6,2][10,7,6,0,0,7,7][7,2,4,4,0,7,0][4,8,6,7,2,1,7]B 转换为符号矩阵;b=sym(B)b =
[3,5,5,0,1,2,3][3,2,5,4,6,2,5][1,2,1,1,3,4,6][3,5,1,5,2,1,2][4,1,0,1,2,0,1][-3,-4,-7,3,7,8,12][1,-10,7,-6,8,1,5]
若某一矩阵为数值矩阵,另以矩阵为符号矩阵,两矩阵相乘是符号矩阵例;a*B=
[48,3,64,48,159,106,194][17,-26,47,-8,62,26,59][48,-8,52,12,108,64,124][59,22,41,69,151,101,184][43,-22,91,13,175,121,220][22,39,4,53,88,94,147][75,11,115,36,151,70,151]
2、利用MATLAB 语言提供的现成函数对习题1中给出的两个矩阵进行分析,判定它们是否
为奇异矩阵,得出矩阵的秩、行列式、迹和逆矩阵,检验得出的逆矩阵是否正确。
解:由于a=det(A)=3.7396e+04;故A 是非奇异矩阵。B=det(B)=0,故B 是奇异矩阵;
由于a=rank(A)=7,故A 的秩为7;由于b=rank(B)=5,故B 的秩为5;由于a=trace(A)=27,b=trace(B)=26,故A,B 的迹为27,26;由a=inv(A)得A 的逆矩阵如下;
-0.47790.2745-0.04710.07580.03710.27340.1526
-0.64100.9104-0.26070.3344-0.10860.37610.0996
0.5246-1.27420.0971-0.18430.3513-0.5163-0.0007
-0.03400.2426-0.0009-0.0173-0.18060.18010.0716
0.1477-0.31650.1920-0.0475-0.0134-0.1360-0.0074
0.38070.05490.0666-0.0562-0.1036-0.0459-0.2216
0.4934-0.26520.1782-0.22860.0010-0.2782-0.0955
由c=norm(A*a-eye(size(A)))得c=8.8386e-15,故正确。
由于B为奇异矩阵,故B没有逆矩阵。
3、试求出习题1中给出的A和B矩阵的特征多项式、特征值与特征向量,并对它们进行LU
分解。
对A矩阵求特征多项式、特征值与特征向量;
由charpoly(A)得[1,-27,-11,-307,6749,37016,13371,-37396];所以特征多项式为f=poly2sym(ans,'x')=x^7-27*x^6-11*x^5-307*x^4+6749*x^3+ 37016*x^2+13371*x-37396
由[v,d]=eig(A)得;特征值为-3.37,-1.47,0.796,7.67,27.4,-2.02+6.39*i, -2.02-6.39*i;
特征向量为:
[ 4.91,-1.14,-0.5,-0.139,0.973,0.449-0.134*i,0.449+0.134*i] [-0.353,-0.684,-2.78,0.522,0.305,-0.35-0.403*i,-0.35+0.403*i] [-10.9,0.283, 3.45,0.0303,0.791,-0.98+0.334*i,-0.98-0.334*i] [ 4.18,-0.188,-0.68,-0.268,0.936,-0.119+1.4*i,-0.119-1.4*i] [ 4.87,0.0608, 1.21,0.0304, 1.04,-0.859-0.678*i,-0.859+0.678*i] [-0.646, 1.06,-0.324,-1.32,0.702,0.415-0.28*i,0.415+0.28*i]
[1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
LU分解;
[l,u]=lu(A)
l=[1,0,0,0,0,0,0]
[2/5,1,0,0,0,0,0]
[6/5,-22,1,0,0,0,0]
[3/5,24,-1,1,0,0,0]
[2,-35,55/36,65/36,1,0,0]
[7/5,-39,59/36,-17/36,3/17,1,0]
[4/5,12,-1/2,-1,-60/119,-102/35,1]
u=[5,7,6,5,1,6,5]
[0,1/5,-7/5,-2,-2/5,-7/5,2]
[0,0,-36,-50,-4,-34,42]
[0,0,0,-2,11,2,-7]
[0,0,0,0,-119/4,-17/3,557/36]
[0,0,0,0,0,5/3,-592/153]
[0,0,0,0,0,0,-18698/1785]
对B矩阵求特征多项式、特征值与特征向量;
由charpoly(B)得ans=1-26245-59317001220000所以特征多项式为f=x^7-26*x^6+245*x^5-593*x^4+1700*x^3+12200*x^2
由[v,d]=eig(B)得;特征值为12.3669+6.6610i,12.3669-6.6610i,1.8504