资源描述:
《MATLAB仿真及电子信息应用答案》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、.MATLAB仿真及电子信息应用第二单元1.>>a=zeros(2)a=0000>>a(1,2)=2a=02002.>>a=[10-23];b=[0121];>>a+bans=1104>>a.*bans=00-43//-4+3=-1>>dot(a,b)ans=-13.>>a=randn(4)a=0.81561.1908-1.6041-0.80510.7119-1.20250.25730.52871.2902-0.0198-1.05650.21930.6686-0.15671.4151-0.9219>>sum(diag(a))..ans=-2.3652>>
2、reshape(a,2,8)ans=0.81561.29021.1908-0.0198-1.6041-1.0565-0.80510.21930.71190.6686-1.2025-0.15670.25731.41510.5287-0.92194.>>a=rand(3,5)a=0.95010.48600.45650.44470.92180.23110.89130.01850.61540.73820.60680.76210.82140.79190.1763>>a(:,4)=a(:,4)+0.2a=0.95010.48600.45650.64470.92180
3、.23110.89130.01850.81540.73820.60680.76210.82140.99190.1763>>lt(a,0.5)ans=0110010100000015.>>a=randn(3,2);b=randn(3,2);>>cat(1,a,b)//按列方向ans=0.73100.67710.57790.56890.0403-0.2556-0.3775-0.2340-0.29590.1184-1.47510.3148>>cat(2,a,b)//按行方向..ans=0.73100.6771-0.3775-0.23400.57790.5689
4、-0.29590.11840.0403-0.2556-1.47510.31486.>>'Helloeveryone'ans=Helloeveryone7.>>str1=['MATLAB'];str2=['isstrong'];str3=[str1,str2]str3=MATLABisstrong8.(1)直接法>>a={'Function''Variable';'y=f(x)''x';'6'[1:5]}a='Function''Variable''y=f(x)''x''6'[1x5double](2)函数法>>a=cell(3,2);a{1,1}='Fu
5、nction';a{1,2}='Variable';>>a{2,1}='y=f(x)';a{2,2}='x';>>a{3,1}='6';a{3,2}=[1:5];>>aa='Function''Variable''y=f(x)''x''6'[1x5double]9.>>student1.Name='Mary';student1.Age='Eighteen';>>student1.Score='502';student1.Class='1';student1student1=Name:'Mary'Age:'Eighteen'..Score:'502'Cla
6、ss:'1'>>student2.Name='Mike';student2.Age='Nighteen';>>student2.Score='498';student2.Class='2';student2student2=Name:'Mike'Age:'Nighteen'Score:'498'Class:'2'>>student3.Name='Joe';student3.Age='Eighteen';>>student3.Score='520';student3.Class='3';student3student3=Name:'Joe'Age:'Eig
7、hteen'Score:'520'Class:'3'第三单元3-1clearallclcp=[54121];roots(p)%求根y=polyval(p,5)%求在5处函数的函数值3-2clearallclcp=[20-25];x=[124;-103;521];f=polyder(p)%多项式求导polyvalm(p,x)3-3clearallclcf=factor(sym('2*x^4-5*x^3+4*x^2-5*x+2'))3-4clearallclcf1=sym('(x^2+1)(x-2)');..f2=sym('2*x^2+1');f=expan
8、d(f1*f2)3-5clearallclc>>symsxy;>>f=log(1