资源描述:
《实验-二-MATLAB矩阵分析与处理.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、实验二MATLAB矩阵分析与处理一、实验目的1.掌握生成特殊矩阵的方法;2.掌握矩阵分析的方法;3.用矩阵求逆法解线性方程组。二、实验内容(1)设有分块矩阵,其中E、R、O、S分别为单位矩阵、随即矩阵、零矩阵和对角阵,试通过数值计算验证。解:E=eye(3);R=rand(3,2);O=zeros(2,3);S=diag([2,3]);A=[E,R;O,S];A^2B=[E,(R+R*S);O,S^2]ans=Columns1through41.0000002.444201.000002.7174001.00000.38100004.00000000Column53.65352.52940.3
2、90209.0000B=Columns1through41.0000002.444201.000002.7174001.00000.38100004.00000000Column53.65352.52940.390209.0000(2).产生5阶希尔伯特矩阵H和5阶帕斯卡矩阵P,且求其行列式的值Hh和Hp以及它们的条件数Th和Tp,判断哪个矩阵性能更好,为什么?解:H=hilb(5)P=pascal(5)Hh=det(H)Hp=det(P)Th=cond(H)Tp=cond(P)H=1.00000.50000.33330.25000.20000.50000.33330.25000.20000.
3、16670.33330.25000.20000.16670.14290.25000.20000.16670.14290.12500.20000.16670.14290.12500.1111P=111111234513610151410203515153570Hh=3.7493e-012Hp=1Th=4.7661e+005Tp=8.5175e+003解析:(3).建立一个矩阵,求它的行列式、迹、秩和各种范数。解:A=fix(10*rand(5))H=det(A)Trace=trace(A)Rank=rank(A)Norm=norm(A)A=2940759983947969896111677H=-
4、12583Trace=31Rank=5Norm=30.16014.已知,求A得特征值及对应的特征向量,并分析其数学意义。解:A=[-29,6,18;20,5,12;-8,8,5][V,D]=eig(A)A=-2961820512-885V=0.71300.28030.2733-0.6084-0.78670.87250.34870.55010.4050D=-25.3169000-10.518200016.8351意义:5.已知线性方程组:⑴求方程组的解;解:A=[1/2,1/3,1/4;1/3,1/4,1/5;1/4,1/5,1/6];b=[0.95,0.67,0.52]';x=inv(A)*b
5、%(2):B=[0.95,0.67,0.53]';x=inv(A)*B%(3):cond(A)x=1.20000.60000.6000x=3.0000-6.60006.6000ans=1.3533e+003⑵将方程组右边向量元素改为0.53,再求解,并比较的变化和解得相对变化;解:A=hilb(4)A(:,1)=[]A(4,:)=[]B=[0.95,0.67,0.52]';X=inv(A)*BB1=[0.95,0.67,0.53]';X1=inv(A)*B1N=cond(B)N1=cond(B1)Na=cond(A)%矩阵A为病态矩阵A=1.00000.50000.33330.25000.50
6、000.33330.25000.20000.33330.25000.20000.16670.25000.20000.16670.1429A=0.50000.33330.25000.33330.25000.20000.25000.20000.16670.20000.16670.1429A=0.50000.33330.25000.33330.25000.20000.25000.20000.1667X=1.20000.60000.6000X1=3.0000-6.60006.6000N=1N1=1Na=1.3533e+003⑶计算系数矩阵A的条件数并分析结论。解:(6.)建立矩阵A,试比较sqrtm(
7、A)和sqrt(A),分析它们的区别。解:解:A=[1,4,9;16,25,36;49,64,81]B=sqrtm(A)C=sqrt(A)%sqrtm函数是以矩阵为单位进行计算,sqrt函数是以矩阵中的元素进行计算A=149162536496481B=0.6344+1.3620i0.3688+0.7235i0.7983-0.4388i1.4489+1.1717i2.7697+0.6224i3.21