matlab7.X课后习题.doc_第1页
matlab7.X课后习题.doc_第2页
matlab7.X课后习题.doc_第3页
matlab7.X课后习题.doc_第4页
matlab7.X课后习题.doc_第5页
已阅读5页,还剩13页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

第二章第三题clc;clear;close alla=5-round(100*rand(50,2)/10a = -4.5000 3.1000 2.7000 -1.8000 -1.1000 2.0000 0.1000 -0.4000 -3.9000 3.5000 -2.6000 -2.0000 0.4000 1.2000 4.8000 -3.6000 -3.2000 -3.5000 0.6000 -0.9000 -1.2000 0 -2.9000 -4.0000 -4.2000 -3.2000 -2.4000 -1.4000 3.2000 -3.2000 0.9000 -1.6000 -4.4000 1.6000 -4.2000 2.1000 0.9000 1.6000 -3.9000 -0.3000 4.4000 -2.3000 1.5000 1.9000 -3.1000 -3.4000 4.9000 -0.7000 3.6000 1.3000 3.0000 -2.0000 3.0000 -0.5000 -1.0000 0.6000 2.3000 -1.9000 3.0000 -1.2000 4.8000 -2.9000 -2.5000 -4.6000 0.5000 -0.2000 -4.3000 -3.8000 0.3000 3.3000 0.8000 -4.8000 -3.5000 2.3000 -0.3000 2.5000 3.0000 -3.8000 -1.7000 -2.4000 -3.4000 3.6000 4.8000 4.9000 -1.8000 -3.9000 1.2000 3.0000 -3.3000 2.0000 0 -1.6000 -2.1000 2.2000 0.7000 0.3000 2.0000 4.40003.1000 -4.9000第六题clc;clear;close alla=randn(10,10)b=find(-0.5a=10 if rem(y,10)=0 i=i+1; end y=fix(y/10); endenddisp(i) 504第五题clc;clear;close alli=1x1=-3:0.01:3;for x=x1 if x=-3&x=-1&x=1&x40 bonus=(number-40)*0.01+20*0.02+10*0.05+10*0.1;elseif number20 bonus=(number-20)*0.02+10*0.05+10*0.1;elseif number10 bonus=(number-10)*0.05+10*0.1;else bonus=number*0.1;endData=sprintf(the bonus is %d,bonus);disp(Data);input the profit150000the bonus is 1.501500e+003第九题clc;clear;close allm=1;n=2;for i=1:1:15 x(i)=n/m; k=n; n=m+n; m=k;endsum(x)ans = 24.5701第五章第一题clc;clear;close alla1=1 9 8;7 2 5;3 -2 7;b1=inv(a1)det(a1)a2=1 0 -7 5;0 -26 7 2;7 4 3 5;8 -3 2 15;b2=inv(a2)det(a2)b1 = -0.0543 0.1787 -0.0656 0.0769 0.0385 -0.1154 0.0452 -0.0656 0.1380ans = -442b2 = 0.1501 0.0654 0.3046 -0.1603 -0.0509 -0.0471 -0.0312 0.0336 -0.1697 -0.0204 -0.0703 0.0827 -0.0676 -0.0416 -0.1593 0.1478ans = -9334第二题clc;clear;close alla1=1 2 3;2 2 5;3 5 1;b1=11 12 31;x1=a1b1a2=3 1 0 5;0 6 7 3;0 4 3 0;2 -1 2 6;b2=2 4 7 8;x2=a2b2x1 = 1.8000 5.2000 -0.4000x2 = 28.1892 -9.4595 14.9459 -14.6216第八题clc;clear;close allp1=1 -2 -3 4 2;r1=roots(p1)p2=1 -7 5 31 -30;r2=roots(p2)p3=1 -1 -25 25;r3=roots(p3)p4=-2 3 1 5 8 0;r4=roots(p4)r1 = 2.4142 1.4142 -1.4142 -0.4142r2 = 5.0000 -2.0000 3.0000 1.0000r3 = -5.0000 5.0000 1.0000r4 = 0 2.4176 0.0148 + 1.3215i 0.0148 - 1.3215i -0.9473 第九题clc;clear;close allp1=1 -2 -3 4 2;y1=polyval(p1,-1.5 2.1 3.5)p2=1 -7 5 31 -30;y2=polyval(p2,-1.5 2.1 3.5)p3=1 -1 -25 25;y3=polyval(p3,-1.5 2.1 3.5)p4=-2 3 1 5 8 0;y4=polyval(p4,-1.5 2.1 3.5)y1 = 1.0625 -1.9039 43.5625y2 = -36.5625 11.7711 -10.3125y3 = 56.8750 -22.6490 -31.8750y4 = 26.2500 24.7733 -468.1250第十三题clc;clear;close alla1=rand(1,50);b1=max(a1)c1=min(a1)m1=mean(a1)s1=std(a1)2a2=randn(1,50);b2=max(a2)c2=min(a2)m2=mean(a2)s2=std(a2)2b1 = 0.9901c1 = 0.0150m1 = 0.5246s1 = 0.0646b2 = 1.4885c2 = -2.2023m2 = -0.2348s2 = 0.8153第十六题clc;clear;close allt=-2:.1:2;x1=sin(50*t)+randn(size(t);x2=cos(50*t)+randn(size(t);x3=sin(50*t)+randn(size(t);r1=corrcoef(x1,x2)r2=corrcoef(x1,x3)X1=randn(size(t);X2=randn(size(t);X3=randn(size(t);R1=corrcoef(X1,X2)R2=corrcoef(X1,X3)r1 = 1.0000 -0.0274 -0.0274 1.0000r2 = 1.0000 0.3374 0.3374 1.0000R1 = 1.0000 -0.0346 -0.0346 1.0000R2 = 1.0000 0.1118 0.1118 1.0000第六章第二题clc;clear;close allr=round(100*rand(7,5,10);r1=reshape(r(:,:,1),1,35);a1=mean(r1)r2=reshape(r(:,:,2),1,35);a2=mean(r2)r3=reshape(r(:,:,3),1,35);a3=mean(r3)r4=reshape(r(:,:,4),1,35);a4=mean(r4)r5=reshape(r(:,:,5),1,35);a5=mean(r5)r6=reshape(r(:,:,6),1,35);a6=mean(r6)r7=reshape(r(:,:,7),1,35);a7=mean(r7)r8=reshape(r(:,:,8),1,35);a8=mean(r8)r9=reshape(r(:,:,9),1,35);a9=mean(r9)r10=reshape(r(:,:,10),1,35);a10=mean(r10)A=a1 a2 a3 a4 a5 a6 a7 a8 a9 a10B,A=sort(A)a1 = 54.1714a2 = 48a3 = 52.4000a4 = 44.8286a5 = 53.2286a6 = 49.2571a7 = 50.7429a8 = 46.0571a9 = 46.1714a10 = 50.8286A = 54.1714 48.0000 52.4000 44.8286 53.2286 49.2571 50.7429 46.0571 46.1714 50.8286B = 44.8286 46.0571 46.1714 48.0000 49.2571 50.7429 50.8286 52.4000 53.2286 54.1714A = 4 8 9 2 6 7 10 3 5 1第七章第二题clc;clear;close allx=-1:.01:1;y=-2*x.2+4;y1=-2*x.2+4+sin(2*pi*x);figure(1)plot(x,y,x,y1),grid ontext(-0.3,4,最大值rightarrow)text(-1.0,4,极大值rightarrow)text(-0.6,2.8,极小值rightarrow)text(-0.1,4.8,极大值rightarrow)text(0.5,1.7,极小值rightarrow)第四题function word(y)i=1;while(any(y) A(i).Name,y=strtok(y); A(i).no=i; A(i).length=length(A(i).

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论