Matlab程序设计教程(第二版)刘卫国课后参考答案解析

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

第二章

1 求下列表达式的值。

(1)

w=sqrt(2)*(1+0.34245*10^(-6))

(2)

a=3.5;

b=5;

c=-9.8;

x=(2*pi*a+(b+c)/(pi+a*b*c)-exp(2))/tan(b+c)+a

(3)

a=3.32;

b=-7.9;

y=2*pi*a^(2)*[(1-pi/4)*b-(0.8333-pi/4)*a]

(4)

t=[2,1-3*i;5,-0.65];

z=1/2*exp(2*t)*log(t+sqrt(1+t^(2)))

2 求下列表达式

A=[-1,5,-4;0,7,8;3,61,7];

B=[8,3,-1;2,5,3;-3,2,0];

(1)

A+6*B A^2-B+eye

(2)

A*B A.*B B.*A

(3)

A/B B\A

(4)

[A,B] [A([1,3],:);B^2]

3 根据已知,完成下列操作

(1)

A=[23,10,-0.778,0;41,-45,65,5;32,5,0,32;6,-9.54,54,3.14];

K=find(A>10&A<25);

A(K)

(2)

A=[23,10,-0.778,0;41,-45,65,5;32,5,0,32;6,-9.54,54,3.14];

B=A(1:3,:) C=A(:,1:2) D=A(2:4,3:4) E=B*C

(3)

E

第三章

1 从键盘输入一个3位数,将它反向输出,如输入639,出数936。f=input('输入一个数:','s');

f(end :-1:1)

2 用if语句

score=input('请输入成绩:');

if score>=90&&score<=100

disp('A');

elseif score>=80&&score<=89

disp('B');

elseif score>=70&&score<=79

disp('C');

elseif score>=60&&score<=69;

disp('D');

elseif score<60&&score>=0;

disp('E');

else

disp('出错');

end

用switch语句

score=input('请输入成绩:');

switch fix(score/10)

case {9,10}

disp('A');

case {8}

disp('B');

case {7}

disp('C');

case {6}

disp('D');

case {0,1,2,3,4,5}

disp('E');

otherwise

disp('出错');

end

第四章1题

1) X=0:10;

Y=x-x.^3/6;

Plot(x,y)

2) t=0:0.01:2*pi;

x=8.*cos(t);

y=4*sqrt(2).*sin(t);

plot(x,y)

2题

M文件:

t=-pi:pi/10:pi;

y=1./(1+exp(-t));

subplot(2,2,1);bar(t,y,'b');

title('bar(t,y,''b'')');axis([-5,5,-3,3]); subplot(2,2,2);stairs(t,y,'k');

title('stairs (t,y,''k'')');axis([-5,5,-3,3]); subplot(2,2,3);stem(t,y,'m');

title('stem (t,y,''m'')');axis([-5,5,-3,3]); subplot(2,2,4);loglog(t,y,'g');

title('loglog(t,y,''g'')');axis([-5,5,-3,3]);

3题

1) t=0:pi/100:2*pi;

y=5*cos(t)+4;

polar(t,y,'-*')

2) t=-pi/3:pi/100:pi/3;

r=5*sin(t).^2./cos(t);

polar(t,r,'-*')

4题

1)

t=0:pi/100:2*pi;

x=exp(-t/20).*cos(t);

y=exp(-t/20).*sin(t);

z=t;

plot3(x,y,z)

第五章:1题

A=randn(10,5)

1) X=mean(A)

Y=std(A,0,1)

2) max(max(A))

min(min(A))

3) B=sum(A,2)

sum(B)

4) sort(A);

sort(A,2,'descend')

2题

1) t=0:15:90;

x1=[0,0.2588,0.5000,0.7071,0.8660,0.9659,1.0000]; a1=0:1:90;

y1=interp1(t,x1,a1,'spline')

x2=[0,0.2679,0.5774,1.0000,1.7320,3.7320,NaN];

a2=0:1:75;

y2= interp1(t,x2,a2,'spline')

p1=polyfit(t,x1,5);

z1=polyval(p1,a1)

p2=polyfit(t,x2,5);

z2=polyval(p2,a2)

4题

P=[2,-3,5,13];

Q=[1,5,8];

p=polyder(P)

p1=polyder(P,Q)

[p,q]= polyder(P,Q)

5题

P1=[1,2,4,0,5];

P2=[1,0];

P3=[1,2,3];

1) P4=conv(P2,P3)

P4=[0,1,2,3,0];

P=P1+P4

2) x=roots(P)

3) A=[-1,1.2,-1.4;0.75,2,3.5;0,5,2.5];

Y=polyval(P,A)

4) Z=polyvalm(P,A)

相关文档
最新文档