2022年Matlab程序设计与应用第二版刘卫国课后实验答案 .pdf
《2022年Matlab程序设计与应用第二版刘卫国课后实验答案 .pdf》由会员分享,可在线阅读,更多相关《2022年Matlab程序设计与应用第二版刘卫国课后实验答案 .pdf(7页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、1 实验一: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=A&ab disp(帕萨卡矩阵P性能更好 ); elseif ab disp(希尔伯特矩阵H 性能更好 ); else disp(两个矩阵性能相同); end T3: a=1:25;
2、A=reshape(a,5,5) disp(行列式的值: ); disp(det(A); disp(矩阵的秩: ); disp(rank(A); disp(矩阵的迹: ); 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 1 页,共 7 页 - - - - - - - - - 2 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、/3,1/4,1/5;1/4,1/5,1/6 B=0.95,0.67,0.52 X1=AB B(3)=0.53 X2=AB 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)5)&(x(i)=2)&(x(i)=3)
4、; 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 (s100) disp(the score is not reasonable); s=input(please enter the score:); end if (s=90&s=80&s=70&s=60&s70); disp(D); else disp(E); end T2-switch: s=input(please enter the score:); while (s100) d
5、isp(the score is not reasonable); s=input(please enter the score:); end switch fix(s/10) case9,10 disp(A); case8 disp(B); case7 disp(C); case6 disp(D); case0,1,2,3,4,5 disp(E); end T3: t=input( 请输入工时time=); if t120 w=120*84+(t-120)*1.15*84; elseif t60 w=t*84-700; else w=84*t; end disp(应发工资为: ); disp
6、(w); T4: a=10+floor(rand(1)*89) b=10+floor(rand(1)*89) 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 2 页,共 7 页 - - - - - - - - - 3 s=input( 请输入 +或-或* 或/,s); while(s=+&s=-&s=*&s=/) disp(输入的符号错误,请重新输入); s=input( 请输入 +或-或*或/,s); end switch s case+ c=a+b; case- c=a-b; c
7、ase* c=a*b; case/ c=a/b; end c T5: A=rand(5,6) n=input( 请输入 n:); while (n5 B=A(5,:) else B=A(n,:) End 实验四:T1: n=input( 请输入 n:); m=0; for i=1:n; m=m+1/i2; end pii=sqrt(6*m) T1-2: n=input( 请输入 n:); m=1./(1:n).2; s=sum(m); pii=sqrt(6*s) T2: n=1000;y=0; for i=1:n; y=y+1/(2*i-1); if y=3 disp(最大 n 值为: );
8、i-1 disp(对应的 y 值为: ); y-1/(2*i-1) break; end end T3: format long a=input( 请输入 a:); b=input( 请输入 b:); x(1)=a/(1.0+b);i=1;x(2)=a/(x(i)+b); while (abs(x(i+1)-x(i)0.00001&i500) i=i+1; x(i+1)=a/(x(i)+b); end r1=(-b+sqrt(b2+4*a)/ 2; r2=(-b-sqrt(b2+4*a)/ 2; disp(x,num2str(i+1),=,num2str(x(i+1),8); disp(x,n
9、um2str(i),=,num2str(x(i),8); disp(r1=,num2str(r1,8),r2=,num2str(r2,8); format short T4: f(1)=1;f(2)=0;f(3)=1;i=4; while(i0) fn=length(find(f0) f0=length(find(f=0) T5: j=0;s=0; for i=3:50 m=i*(i-1)-1; if isprime(m)=1 m 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 3
10、页,共 7 页 - - - - - - - - - 4 s=s+m; j=j+1; end end disp(亲密数的对数:,num2str(j); disp(所有亲密素数之和:,num2str(s); 实验五:fn1: function f=fn1(n) f=n+10*log(n.2+5); fn2: function f=fn2(n) f=0; for i=1:n f=f+i*(i+1); end fx: function f=fx(x) f=1./(x-2).2+0.1)+1./(x-3).4+0.01); T1: x=input( 请输入一个复数:); fe=exp(x) flg=lo
11、g(x) fsin=sin(x) fcos=cos(x) T2: m1=input( 请输入 m1:); m2=input( 请输入 m2:); t=input( 请输入 theta:); A=m1*cos(t),-m1,-sin(t),0;m1*sin(t),0,. cos(t),0;0,m2,-sin(t),0;0,0,-cos(t),1 B=0,m1*9.8,0,m2*9.8 disp(a1,a2,N1,N2=); disp(AB); T3: j=1;n=1;k=1; for i=10:99 % 挑选出1099 中所有的素数if isprime(i)=1 m(j)=i; j=j+1; e
12、nd end for t=1:length(m); s(n)=10*rem(m(t),10)+fix(m(t)/10); %挑选出的素数进行位置交换if isprime(s(n)=1 %再挑选出交换绝对素数r(k)=m(t); k=k+1; end n=n+1; end disp(所有两位绝对素数:,num2str(r) T5: y1=fn1(40)/(fn1(30)+fn1(20) %函数调用y2=fn2(40)/(fn2(30)+fn2(20) 实验六:T1: x=linspace(0,2*pi,101); y=(0.5+3*sin(x)./(1+x.2).*cos(x); plot(x,
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 2022年Matlab程序设计与应用第二版刘卫国课后实验答案 2022 Matlab 程序设计 应用 第二 卫国 课后 实验 答案
限制150内