云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > Matlab程序设计与应用第二版刘卫国课后实验答案

Matlab程序设计与应用第二版刘卫国课后实验答案

  • 62 次阅读
  • 3 次下载
  • 2025/5/7 22:40:08

实验一: T1:

%%第一小题

z1=2*sin(85*pi/180)/(1+exp(2))

%%第二小题

x=[2,1+2i;-0.45,5];

z2=1/2*log(x+sqrt(1+x.^2));

z2

%%第三小题

a=-3.0:0.1:3.0;

z3=1/2*(exp(0.3*a)-exp(-0.3*a)).*sin(a+

0.3)+log((0.3+a)/2)

%%第四题

t=0:0.5:2.5

z4=(t>=0&t<1).*(t.^2)+(t>=1&t<2).*(t

.^2-1)+(t>=2&t<3).*(t.^2-2*t+1) T2:

A=[12,34,-4;34,7,87;3,65,7] B=[1,3,-1;2,0,3;3,-2,7] disp ('A+6*B='); disp(A+6*B); disp('A-B+I=');

.

disp(A-B+eye(3));

disp('A*B=');

disp(A*B);

disp('A.*B=');

disp(A.*B);

disp('A^3=');

disp(A^3);

disp('A.^3=');

disp(A.^3);

disp('A/B=');

disp(A/B);

disp('B\\A=');

disp(B\\A);

disp('[A,B]=');

disp([A,B]);

disp('[A([1,3],:);B^2]='); disp([A([1,3],:);B^2]); T3: z=1:25;

A=reshape(z,5,5)';

B=[3,0,16;17,-6,9;0,23,-4;9,7,0;4,13,11];C=A*B

-

D=C(3:5,2:3) T4-1: a=100:999;

b=find(rem(a,21)==0); c=length(b) T4-2:

a=input('请输入一个字符串:','s'); b=find(a>='A'&a<='Z'); a(b)=[]; disp(a); 实验二: T1:

E=eye(3),R=rand(3,2),O=zeros(2,3),S=diag([1,2]); A=[E,R;O,S] disp('A^2='); disp(A^2);

disp('[E,R+RS;O,S^2]'); B=[E,R+R*S;O,S^2] T2: H=hilb(5) P=pascal(5)

.

Hh=det(H) Hp=det(P) Th=cond(H) Tp=cond(P) a=abs(Th-1); b=abs(Tp-1); if a>b

disp('帕萨卡矩阵P性能更好'); elseif a

disp('希尔伯特矩阵H性能更好');else

disp('两个矩阵性能相同'); end T3: a=1:25;

A=reshape(a,5,5) disp('行列式的值:'); disp(det(A)); disp('矩阵的秩:'); disp(rank(A)); disp('矩阵的迹:'); disp(trace(A));

-

disp('矩阵的范数:'); disp(norm(A)); T4:

A=[-29,6,18;20,5,12;-8,8,5] [V,D]=eig(A) T5:

A=[1/2,1/3,1/4;1/3,1/4,1/5;1/4,1/5,1/6]B=[0.95,0.67,0.52]' X1=A\\B B(3)=0.53 X2=A\\B

disp('系数矩阵A的条件数:'); disp(cond(A)); T6: a=1:25;

A=reshape(a,5,5) disp('B1=sqrtm(A)'); B1=sqrtm(A) disp('B2=sqrt(A)'); B2=sqrt(A) disp('B1*B1'); B1*B1

.

disp('B2.*B2'); B2.*B2 实验三: T1:

x=-5.0:2:5.0 for i=1:length(x); if (x(i)<0)&(x(i)~=-3) y(i)=x(i)^2+x(i)-6; elseif

(x(i)>=0)&(x(i)<5)&(x(i)~=2)&(x(i)~=3);

y(i)=x(i)^2-5*x(i)+6; else

y(i)=x(i)^2-x(i)-1; end end y T2-if:

s=input('please enter the score:'); while (s<0||s>100)

disp('the score is not reasonable'); s=input('please enter the score:');

-

end

if (s>=90&s<=100); disp('A'); elseif(s>=80&s<90); disp('B'); elseif(s>=70&s<80); disp('C'); elseif(s>=60&s<70); disp('D'); else

disp('E'); end T2-switch:

s=input('please enter the score:'); while (s<0||s>100)

disp('the score is not reasonable'); s=input('please enter the score:'); end

switch fix(s/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'); end T3:

t=input('请输入工时time='); if t>120

w=120*84+(t-120)*1.15*84;elseif t<60

w=t*84-700; else

w=84*t; end

disp('应发工资为:'); disp(w); T4:

a=10+floor(rand(1)*89) b=10+floor(rand(1)*89)

-

  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

实验一: T1: %%第一小题 z1=2*sin(85*pi/180)/(1+exp(2)) %%第二小题 x=[2,1+2i;-0.45,5]; z2=1/2*log(x+sqrt(1+x.^2)); z2 %%第三小题 a=-3.0:0.1:3.0; z3=1/2*(exp(0.3*a)-exp(-0.3*a)).*sin(a+0.3)+log((0.3+a)/2) %%第四题 t=0:0.5:2.5 z4=(t>=0&t=1&t<2).*(t.^2-1)+(t>=2&t<3).*(t.^2-2*t+1) T2: A=[12,34,-4;34

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com