matlab大作业例子36.docxVIP

  • 7
  • 0
  • 约1.76千字
  • 约 17页
  • 2018-05-02 发布于贵州
  • 举报
matlab大作业例子36

Matlab作业题目1:(1)程序部分: x=0:pi/50:2*pi; y=cos(0.5+((3*sin(x))./(1+x.^2))); plot(x,y) xlabel(x);ylabel(y);title(x-y);(2)运行结果截图:题目2(1)程序部分: clearclc x=0:pi/100:4*pi; y1=sin(x); y2=cos(x); plot(x,y1,r-,x,y2,g:) hold on y3=x(find(abs(y1-y2)0.001)); plot(y3,sin(y3),*)(2)运行结果截图:题目3(1)程序部分: t=(0:2*pi/100:2*pi); y1=sin(t)*[1,-1]; y2=sin(t).*sin(9*t); subplot(2,1,1); plot(t,[y1,y2]); subplot(2,1,2); plot(t,[y1,y2])(2)运行结果截图:题目4(1)程序部分: t=0:pi/50:4*pi; y=exp(-t/3); y0=exp(-t/3).*sin(3*t); plot(t,y,r-,t,y0,b:) xlabel(\bf\it t) ylabel(\bf\it y) grid on;(2)运行结果截图:题目5(1)程序部分: n=0; sum=0; while sum2000n=n+1;sum=sum+n;end n(2)运行结果截图:题目6(1)程序部分:for j=1:3n=input(n=);sum=0;for i=1:na=1/(i.^2);sum=sum+a;endPI=sqrt(6*sum)end(2)运行结果截图:题目7(1)程序部分:n0=0;y0=0;while 3*y05n0=n0+1;y0=y0+1/(2*n0-1);y=y0-1/(2*n0-1);n=n0-1;endny(2)运行结果截图:题目8(1)程序部分:for i=1:7x=input(put x:);if x0x~-3y=x^2+x-6;elseif x=0x5x~=3x~=2y=x*x-5*x+6;elsey=x*x-x-1;endyend(2)运行结果截图:题目9①switch语句 (1)程序部分: 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,5}disp(E); otherwisedisp(error); end(2)运行结果截图:如右图②if语句(1)程序部分:score=input(请输入成绩:) n=score/10;if n=9n10disp Aelseif n=8n9disp Belseif n=7n8disp Celseif n=6n7disp Delseif n=0n6disp Eelsedisp errorend(2)运行结果截图:题目10(1)程序部分: t=input(员工的工作时间:) if t60 m=84*t-700;elseif t120 m=84*(t-120)*1.15+84*120; else m=84*t; end m2)运行结果截图:题目11(1)程序部分:a=round(20*rand(5,6))n=input(请输入n的值:)try b=a(n,:);catchb=a(5,:);endblasterr(2)运行结果截图:

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档