资源描述:
《Matlab数学实验(胡良剑)第二章课后习题答案》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、Matlab数学实验(胡良剑)1.x=[81,70,65,51,76,66,90,87,61,77];a=mean(x)b=std(x)2.s=0;forn=0:100s=s+log(1+n);ifs>100break;endendn3.F=[1,1];forn=3:100F(n)=F(n-1)+F(n-2);endFform=2:100a=F(m)/F(m-1);ifabs(a-((1+sqrt(5))/2))<10^(-8)break;endendm4.clear;K=0;fori=1:1000000K=K+sqrt(3)/(2^i);endKK=
2、0;i=1;whilei<=10^6K=K+sqrt(3)/(2^i);i=i+1;endKi=1:1000000;K=sum(sqrt(3)./(2.^i));K5.(1)t=[0123456789101112131415161718192021222324];T=[15141414141516182022232528313231292725242220181716];plot(t,T);(2)dlmwrite('Tem.txt',[t;T]','delimiter','b');(3)6.(1)subplot(1,2,1);fplot(@(x)x^
3、2*sin(x^2-x-2),[-2,2],'r');x=-2:0.1:2;y=x.^2.*sin(x.^2-x-2);subplot(1,2,2);plot(x,y,'b:');(2)ezplot('(x^2)/4+(y^2)/9-1',[-2,2,-3,3]);(3)[x,y]=meshgrid(-3:0.1:3);z=x.^2+y.^2;mesh(x,y,z);(4)xa=-3:0.1:3;ya=-3:0.2:13;[x,y]=meshgrid(xa,ya);z=x.^4+3*x.^2+y.^2-2*x-2*y-2*x.^2.*y+6;mesh(
4、x,y,z);(5)t=0:pi/360:2*pi;x=sin(t);y=cos(t);z=cos(2*t);plot3(x,y,z);gridon;(6)aa=0:pi/180:2*pi;bb=0:pi/360:pi/2;[a,b]=meshgrid(aa,bb);x=2*sin(b).*cos(a);y=2*sin(b).*sin(a);z=2*cos(b);mesh(x,y,z);(7)x=0:pi/180:pi;y1=sin(x);y2=sin(x).*sin(10*x);y3=-sin(x);plot(x,y1,'b-',x,y2,'r+-'
5、,x,y3,'gx-');xlabel('x');ylabel('y');axis([0pi+1-1.51.5]);text(pi/2,1.1,'yl=sinx');text(pi/(3.5),0.5,'y2=sin{x}sin{10x}');text(pi/2,-1.1,'y3=-sinx');legend('y1','y2','y3');7.x=-3.3:0.1:3.3;y=-1.1*(x<-1.1)+x.*(x>=-1.1&x<=1.1)+1.1*(x>1.1);plot(x,y);title('y函数');xlabel('X');ylabel(
6、'Y');8.9.函数文件P.mfunctionPxy=P(x,y)Pxy=0.5457*exp(-0.75*y.^2-3.75*x.^2-1.5*x).*(x+y>1)...+0.7575*exp(-y.^2-6*x.^2).*(x+y>-1)...+0.5457*exp(-0.75*y.^2-3.75*x.^2+1.5*x).*(x+y<=-1);end命令文件[x,y]=meshgrid(-3:0.1:3);s=size(x);Pxy=zeros(s(1),s(2));fori=1:s(1)forj=1:s(2)Pxy(i,j)=P(x(i,j)
7、,y(i,j));endendmesh(x,y,Pxy);10.A=[123;456;780];C=[2-5-22;-5-24-56;-22-56-16];X=lyap(A,C);X