精讲多练MATLAB(第二版)课后习题答案

  • 格式:doc
  • 大小:44.50 KB
  • 文档页数:7

第1章练习题答案 1-2. A=1.2 ;B=-4.6 ;C=8.0 ;D=3.5 ;E=-4.0; T=atan((2*pi*A+E/(2*pi*B*C))/D) 1-3 clear x=45; (sin(x*pi/180)+sqrt(35))/(72^(1/5)) 1-4 clear a=5.67;b=7.811; exp(a+b)/log10(a+b) 1-5 clear x=3; y=sqrt(x)-6*(x+1/x)+(x-3.2)^2/(x+7.7)^3 1-6 clear r=15; d=2*r c=2*pi*r s=pi*r*r 1-7 clear a=8.5;b=14.6;c=18.4; s=(a+b+c)/2; area=sqrt(s*(s-a)*(s-b)*(s-c)) 第2章练习题答案 2-1 clear A=[ 3 1 1;2 1 2;1 2 3]; B=[1 1 -1;2 -1 0;1 -1 1]; 2*A+B,4*(A^2)-3*(B^2),A*B,B*A,A*B-B*A 2-2 clear A=[1/3 0 0;0 1/4 0;0 0 1/7]; B=inv(inv(A)-eye(3))*6 2-3 clear B=[1 2 -3 -2;0 1 2 -3;0 0 1 2;0 0 0 1]; C=[1 2 0 1;0 1 2 0;0 0 1 2;0 0 0 1]; A=(inv(2*eye(4)-inv(C)*B)*inv(C))' 2-4 clear A=[2 -1;-1 2]; B=[0 -2;-2 0]; X=(1/2)*(B+2*A) 2-5 clear A=[2 -3 0 2;1 5 2 1;3 -1 1 -1;4 1 2 2]; B=[8;2;7;12]; X=A\B 2-6 A=[3 12 4 7 0 8 1]; p=poly2str(A,'x') x=roots(A) 2-7 A=[3 12 4 7 0 8 1]; B=[1 -3 5 -15 0]; [div,rest]=deconv(A,B)

第三章 3-1.x=sym('x'); limit((cos(sqrt(x)))^(pi/x),x,0,'right') ans =exp(-1/2*pi) 3-2.x=sym('x'); f=sym('(3*sin(x)+x^2*cos(1/x))/((1+cos(x))*log(1+x))'); limit(f,x,0) ans =3/2 3-3.x=sym('x'); f=sym('(sqrt(4*x^2+x-1)+x+1)/sqrt(x^2+sin(x))'); limit(f,x,-inf) ans =1 3-4.syms x y; f=sym('(x^2+y^2)^(x^2*y^2)'); limit(limit(f,x,0),y,0) ans =1 3-5.x=sym('x'); y=sym('(tan(sqrt(x+sqrt(x+sqrt(2*x)))))^2'); diff(y,x) ans =tan((x+(x+2^(1/2)*x^(1/2))^(1/2))^(1/2))*(1+tan((x+(x+2^(1/2)*x^(1/2))^(1/2))^(1/2))^2)/(x+(x+2^(1/2)*x^(1/2))^(1/2))^(1/2)*(1+1/2/(x+2^(1/2)*x^(1/2))^(1/2)*(1+1/2*2^(1/2)/x^(1/2))) 3-6. x=sym('x'); y=sym('cos(x^2)*sin(1/x)^2'); diff(y,x) ans =-2*sin(x^2)*x*sin(1/x)^2-2*cos(x^2)*sin(1/x)*cos(1/x)/x^2 3-7. x=sym('x'); y=sym('sqrt(sin(x)-sin(x)^3)'); int(y,x,0,pi) ans =4/3 3-8.x=sym('x'); y=sym('sqrt((x+1)/(x-1))/x'); int(y,x) ans =-((1+x)/(x-1))^(1/2)*(x-1)*(atan(1/(-1+x^2)^(1/2))-log(x+(-1+x^2)^(1/2)))/((1+x)*(x-1))^(1/2) 3-9.dsolve('D2y+4*Dy+4*y=exp(-2*x)','x') ans = 1/2*exp(-2*x)*(2*C2+2*x*C1+x^2) 3-10. dsolve('x^2*Dy+x*y=y^2','y(1)=1') ans =x*exp(1/x)/(exp(1/x)+exp(1/x*t)*x-exp(1/x*t))

第四章 4-1. plot([1 2 4 0 5 10 11 21 3 1]) 4-2. t=0:pi/100:2*pi; x=cos(t); y=sin(t); plot(x,y); axis('square'); 4-3. R=[1 5 10 20]; I=0:0.1:10; U=I'*R; plot(I,U); 4-4. mon=1:12; temp=[0.2 2.3 8.7 18.5 24.6 32.1 36.8 37.1 28.3 17.8 6.4 -3.2]; rainf=[4.6 3.6 2.1 2.9 3.0 2.7 2.2 2.5 4.3 3.4 2.1 3.7]; plot(mon,temp,'r-p',mon,rainf,'b:s'); xlabel('month'); ylabel('temperature and rainfall'); %title('Temperature and Rainfall Curve'); %text(3,1,'rainfall'); %text(9,28.3,'temperature'); flag=12; while(flag)

text(mon(flag),temp(flag),[num2str(mon(flag)),num2str(temp(flag))]);

text(mon(flag),rainf(flag),[num2str(mon(flag)),num2str(rainf(flag))]); flag=flag-1; end 4-5. A=[1 1 1 1 1 1 1;1 2 2 2 2 2 1;1 2 2 3 2 2 1;1 2 2 2 2 2 1;1 1 1 1 1 1 1]; plot(A); 4-6. x=-10:0.5:10; y=x; [X,Y]=meshgrid(x,y); Z=X.^2+Y.^2; surf(X,Y,Z); 4-7. clc clear theta=(0:0.1:2)*pi; phi=(0:0.1:2)*pi; x=zeros(length(theta),length(phi)); y=x; z=x; for i=1:length(theta) for j=1:length(phi) x(i,j)=2*sin(theta(i))*cos(phi(j)); y(i,j)=3*sin(theta(i))*sin(phi(j)); end z(i,:)=4*cos(theta(i)); end axis square

subplot(2,2,1); mesh(x,y,z) title('三维')

subplot(2,2,2); mesh(x,y,z) view(90,0) title('X轴视图')

subplot(2,2,3); mesh(x,y,z) view(0,0) title('Y轴视图') subplot(2,2,4); mesh(x,y,z) view(0,90) title('Z轴视图')

第五章 5-1: clear; x=-2:0.01:2; for ii=1:401 if(x(ii)<0) y(ii)=x(ii)+1; elseif (x(ii)<1)&(x(ii)>=0) y(ii)=1; elseif(x(ii)>=1) y(ii)=x(ii)^3; end end plot(x,y);

5-2: function y=fenduan(x) if(x<0) y=x+1; elseif (x<1)&(x>=0) y=1; elseif(x>=1) y=x^3; end

5-3: 建立文件arcsin.m如下: function y=arcsin(x) if abs(x)>1 disp('输入参数的绝对值必须小于1'); return; end n=0; y=0; u=x; while u>eps u=(jiecheng(2*n)*x^(2*n+1))/(2^(2*n)*(jiecheng(n)^2*(2*n+1))); y=y+u;