Matlab基础与应用教程答案(人民邮电出版社).docx
第1章一、思索题4. (1)B=A(2:5,1:2:5)(2) A(7)=(3) A=A+30(4) size(八)(5) t(find(t=O)=eps(6) t=reshape(x,3,4)(7) abs('matlab,)(8) char(93)54z7;9,3,0;5. A=97,67,34,10;-78,75,65,5;32,5,-23,-59;0,-12,(1) B=A(I:3,:)C=A(:,1:2)D=A(2:4,3:4)E=B*C(2)A(find(A>=50&A<=100)二、试验题l.x=-74/180*pi;y=-27/180*pi;sin(x*x+y*y)sqrt(tan(abs(x+y)+pi2.a=-3.0:0.1:3.0;exp(-0.3*a).*sin(a+0.3)3.x=2,4;-0.45,5;log(x+sqrt(l+x.*x)/24 .A=3,54,2;34,-45,7;87,90,15;B=I,-2,67;2,8,74(1)A*Bans=12943241977-407-105240259112489A.*Bans=3-10813468-3605187832700(2)Aa3ans=-28917240246-4368137883-2591012766917133325250438673A.a3ans=27157464839304-911253436585037290003375(3)A/Bans=-5.88455.3549-0.20286.3554-5.65964.3293-6.63256.20789.0241B/Aans=30.285519.2643-8.561433.439421.1547-9.3974-0.7443-0.39380.2830(4)AzBans=35421-26734-4572874879015930A(lz3,:)B2ans=3542879015600183-816842827261568255 .a=l+2i;b=3+4i;c=exp(pi*i6)c=0.8660+0.5000ic+a*b(a+b)ans=1.6353+1.8462i第2章一、思索题6 .s=0;forn=0:63s=s+2n;enddisp(s)n=0:63;s=sum(2.n)二、试验题1.x=input('输入一个四位整数:;y=fix(x1000)zmod(£ix(x100),10)zmod(fix(x10),10)zmod(xr10)z=mod(y+7),10)x=z(3)*1000+z(4)*100+z(1)*10+z(2)2.gh=input(,输入工号');h=input('输入工时');dj=84;ifh>120gz=dj*120+1.15*dj*(h-120);elseifh<60gz=dj*h-700;elsegz=dj*h;endformatbank;display(ghzgz)3.循环结构n=input(,inputn:');s=0;fork=l:ns=s+lk2;enddisplay(sqrt(s*6)向量运算n=input('inputn:');k=l:n;display(sqrt(sum(1./k.2)*6)4.y=0;k=0;whiley<3k=k+l;y=y+l(2*k-l);enddisplay(k-lzy-l(2*k-l)5.x0=0;x=l;k=0;a=input(,a=,);b=input(,b=');whileabs(x-x)>=le-5&&k<500x=x;x=a(b+x);k=k+l;enddisplay(krx);display(-b+sqrt(b2+4*a)/2,(-b-sqrt(b2+4*a)2);6.y=fun(40)/(fun(30)+fun(20)(1)函数文件fun.mfunctionf=fun(n)f=n+log(n2+5);(2)函数文件fun.mfunctionf=fun(n)a=l:n;f=sum(a.*(a+l);第3章一、思索题4.t=0:0.01:1.5;y=sqrt(3)2*exp(-4*t).*sin(4*sqrt(3)*t+pi3);5.x=-10:0.01:10;y=linspace(-6,6,size(xz2)z=x.A3+3*x.*y.a2;plot3(x,y,z)6.x=100:100:400;y=100:100:400;z=636z697z624z478;698z712z630z478;680z674,598z412;662r626z552z334;X,Y=meshgrid(xry);mesh(X,Yzz)二、试验题1.(1) x=-10:0.01:10;plot(xx-x.a332)(2) plot(xzexp(-x.*x2)2pi)(3) x=-8:0.01:8;plot(x,sqrt(64-x.*x)/2)(4) t=0:pi/100:6*pi;plot(t.*sin(t)zt.*cos(t)2. (1)Xl=Iinspace(0,1z100);yl=2*xl-0.5;t=linsace(0ziz100);x=sin(3*t).*cos(t);y=sin(3*t).*sin(t);plot(xlzyl,'r-'zx,yz'b:,);text(0.4zl,'y=2x-0.5,);text(-0.4,0.5,x=sin(3t)cos(t),);text(-0.40.3z,y=sin(3t)sin(t),);(2)subplot(1,2,1);scatter(xlryl,10)title(,y=2x-0.5,);subplot(1,2,2);scatter(x,y,10)3.subplot(l,2zl);x=l:1:100;y=sin(1.x);plot(x,y)subplot(1,2z2);fplot(,sin(lx),zlz100)4.subplot(2,2zl);bar(t,y);subplot(2z2z2);stairs(tzy);subplot(2,2,3);stem(t,y)subplot(2,2,4);Semilogy(t,y);5.theta=linspace(-pizpi,100);ro=5.*cos(theta)+4;polar(thetazro);fi=linspace(0r2*pi,100);a=lr=a.*(l+cos(fi);polar(fizr);6.t=0:pi/20:2*pi;x=exp(-t./20).*cos(t);y=exp(-t./20).*sin(t);z=t;Plot3(×,yfz);t=0:0.01:1;x=t;y=t.a2;z=t.a3;plot3(x,yrz);7.x=-30:0.1:0;y=0:0.1:30;xzy=meshgrid(x,y);z=10.*sin(sqrt(x.2+y.a2).sqrt(l+x.A2+y.a2);meshe(×,yfz);8.X=Iinspace(-3,3z100);y=linspace(-3z3z100);xy=meshgrid(x,y);fxy=-5./(1+x.A2+y.a2);i=find(abs(x)<=0.8&abs(y)<=0.5);fxy(i)=NaN;surf(x,yzfxy)9.U=Iinspace(1z10z100);V=Iinspace(-pizpiz100);urv=meshgrid(u,v);x=3.*u.*sin(v);y=2.*u.*cos(v);z=4*u.a2;x=3*u.*sin(v);y=2*u.*cos(v);z=4*u.a2;surf(x,yzz);shadinginterp;light('position',1z0,1);10.t=0:pi/100:2*pi;y=sin(t);comet(tzy)第4章一、思索题5.(1) A=eye(3);(2) C=100+(200-100)*rand(5,6);(3) D=l+sqrt(0.2)*randn(1z500);(4) E=ones(size(八));(5) A=A+30*eye(size(八));(6) B=diag(diag(八))二、试验题1.P=pascal(5);H=hilb(5);Dp=det(P);Dh=det(三);K=cond(P);Kh=cond(三);P矩阵的性能更好,因为KP较小2.A=l,-l,2,3;0,9,3,3;7,-5,0,2;23,6,8,3B=3,p工/2,45;32,-76,Sqrt(37);5z72z4.5e-4;exp(2)z0z97Al=diag(八);Bl=diag(B);A2=triu(八);B2=triu(B);A3=tril(八);B3=tril(B);rA=rank(八);rB=rank(B);nA=nonn(八);nb=norm(B);cA=cond(八);cB=cond(B);3.A=31,lz0;-4,-l,0;4,-8z-2:VzD=ig(八);4.A=diag(-lz-l,-lz-lz-l)+diag(-lz-lz-lz-lzl)+diag(2z2z2z2z2)b=lz0,0z0z0'xl=inv(八)*b;×2=Ab;L,U=lu(八);x3=U(Lb);Q,R=qr(a);Q,R=qr(八);x4=R(Qb)R=chol(八);x5=R(R,b)5.B=sparse(八);×l=inv(B)*b;×2=Bb;LzUJ=Iu(B);x3=U(Lb);第5章一、思索题3.A=randn(10,5);mean(八)std(八)max(max(八))min(min(八))SUm(A,2)sum(sum(八))sort(A,1)sort(A,2,'descend')二、试验题1.A=rand(l,30000);mean(八)std(八)max(八)min(八)size(find(A>0.5)/size(八)2.h=466r715,950z1422z1635;w=7.04z4.28,3.40z2.52,2.13;hh=500z900z1500