..MATLAB仿真及电子信息应用第二单元1.a=zeros(2)a=0000a(1,2)=2a=02002.a=[10-23];b=[0121];a+bans=1104a.*bans=00-43//-4+3=-1dot(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.9219sum(diag(a))..ans=-2.3652reshape(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.1763a(:,4)=a(:,4)+0.2a=0.95010.48600.45650.64470.92180.23110.89130.01850.81540.73820.60680.76210.82140.99190.1763lt(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-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}='Function';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'Class:'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:'Eighteen'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-4clearall..clcf1=sym('(x^2+1)(x-2)');f2=sym('2*x^2+1');f=expand(f1*f2)3-5clearallclcsymsxy;f=log(1+x);g=2*sin(y);compose(f,g)compose(g,f)3-6clearallclcsymsx;finverse(cos(1+x))3-7(1)(2)clearallclcsymsxyk;f1=(1/2^x)+((-1)^x/x^2);f2=[1/(1+k^2)1/(2*k+1)]s1=symsum(f1,1,inf)s2=symsum(f2,1,inf)(3)(4)(5)(6)clearallclcsymsx;f1=(1+2^x)^(1/x);f2=(x^2)*exp(1/x^2);f3=log(tan(x))/sin(x);f4=(x/(2*x+1))^(x-1);limit(f1,inf)limit(f2,0)limit(f3,x,0,'right')limit(f4,inf)(7)(8)clearallclcsymsxyzab;f1=1/(1+x^2);f2=(x^2+y^2+z^2);..int(f1,x,a,b)int(int(int(f2,z,sqrt(x*y),x*y),y,sqrt(x),x),x,0,1)3-8clearallclcsymsx;f=[x*exp(x)log(sin(x));1/(1+x^2)x^(3/2)];diff(f,2)3-9(1)clearallclcf=sym('x^3-2*x+5');solve(f)(2)clearallclcsymsx1x2x3;f1=2*x1-5*x2+3;f2=5*x1-2*x2+18;[x1x2]=solve(f1,f2)(3)方法一:clearallclcsymsx1x2x3;f1=3*x1+11*x2-2*x3-8;f2=1*x1+1*x2-2*x3+4;f3=x1-x2+x3-3;[x1x2x3]=solve(f1,f2,f3)方法二:clearallclcA=[311-2;11-2;1-11];B=[8;-4;3];x=A\B(4)clearallclcsymsx1x2x3;f1=2*x1-x2-exp(-x1);f2=x1-2*x2-exp(-x2);[x1x2]=solve(f1,f2)3-10..clearallclcdsolve('D2y+2*Dy+2*y=0','y(0)=0','Dy(0)=1')3-11clearallclc[xy]=dsolve('Dx=y,Dy=(-1)*x','x(0)=1,y(0)=2')