资源描述:
《实验二matlab矩阵的初等运算及其答案》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、实验二Matlab矩阵的初等运算实验目的:掌握Matlab的运算方法实验内容:2.1在Matlab命令窗口输入:H1=ones(3,2)H2=zeros(2,3)H3=eye(4)观察以上各输入结果,并在每式的后面标注其含义。11>>formatcompact>>H1=ones(3,2),disp('3行2列的全1矩阵')H1=1111113行2列的全1矩阵>>H2=zeros(2,3),disp('2行3列的全零矩阵')H2=0000002行3列的全零矩阵>>H3=eye(4),disp('4阶的单位矩阵')H3=10000100001000014阶的单位矩阵112.2已
2、知,,,,试把这四个矩阵组合为一个大矩阵,看看有几种组合方式?811>>formatcompact>>Q=[123;456];P=[789];R=[1;0];S=3;>>[Q,R;P,S]ans=123145607893>>[R,Q;P,S]ans=112304567893>>[Q,R;S,P]ans=123145603789>>[R,Q;S,P]ans=112304563789>>[S,P;R,Q]ans=378911230456>>[S,P;Q,R]ans=378912314560>>[P,S;R,Q]ans=789311230456>>[P,S;Q,R]ans=789
3、3123145601111112.4建立一个字符串向量,删除其中的大写字母。提示:利用find函数和空矩阵。11>>a='ABCDefgijKLMN123'a=ABCDefgijKLMN123>>k=find(a>='A'&a<='Z')k=123410111213>>a(k)=[]a=efgij1232.3在命令窗中分别输入who和whos,观察检查结果是否与2.1-2.4所得结果相符。11>>whoYourvariablesare:H1H2H3PQRSaansk>>whosNameSizeBytesClassAttributesH13x248doubleH22x348d
4、oubleH34x4128doubleP1x324doubleQ2x348doubleR2x116doubleS1x18doublea1x816charans3x496doublek1x864double2.5已知矩阵,计算以下表达式的结果,体会*,^,sqrtm,expm与.*,.^,sqrt,exp的区别。(1)r1=S^2,r2=2.^S,r3=S.^2,(2)u1=sqrtm(S),v1=u1*u1(3)u2=sqrt(S),v2=u2.*u2(4)u3=expm(S),v3=logm(u3)(5)u4=exp(S),v4=log(u4)>>S=[13125;470
5、9;7162;82113]11S=131254709716282113>>r1=S^2r1=1374613971104791471106938142621175519589>>r2=2.^Sr2=284096321612815121282644256420488>>r3=S.^2r3=191442516490814913646441219>>u1=sqrtm(S)u1=1.2986+1.7799i0.4954-0.2316i2.0525-1.3122i0.8339-0.4347i0.1988+0.0151i2.5282+0.0310i-1.5443+1.1209i2.762
6、0-0.8042i1.1737-0.8736i0.1302+0.1172i2.0959+0.7645i0.4126+0.1282i1.6679-0.6304i0.2883+0.0538i2.9002-0.5041i0.6973+0.8391i>>v1=u1*u1v1=1.0000-0.0000i3.0000+0.0000i12.0000-0.0000i5.0000+0.0000i4.0000+0.0000i7.0000-0.0000i0.0000-0.0000i9.0000+0.0000i7.0000+0.0000i1.0000-0.0000i6.0000+0.0000i2
7、.0000-0.0000i8.0000+0.0000i2.0000-0.0000i11.00003.0000-0.0000i>>u2=sqrt(S)u2=1.00001.73213.46412.23612.00002.645803.00002.64581.00002.44951.41422.82841.41423.31661.7321>>u3=expm(S)11u3=1.0e+008*0.79050.38091.18930.59290.90660.43691.36400.68000.61280.29530.9219