《2023年MATLAB实验报告.pdf》由会员分享,可在线阅读,更多相关《2023年MATLAB实验报告.pdf(14页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、M ATLAB实验报告班级:i o自动化姓名:王万飞学号:181.在 0W x W2兀区间内 y=2e 0.5 xc o s(4 n x)程序如下:x=0:p i/1 0 0:2*p i;y=2*exp(-0.5*x).*c o s(4*p i*x);2绘制曲线。程序如下:t=0:0.1:2*pi;x=t.*si n(3*t);y=t.*s i n(t).*sin(t);3分析下列程序绘制的曲线 x 1=Iinspac e(0,2*pi,100);x2=1 in s p ace(0,3*pi,1 00);x 3=Iinspace(0,4*pi,1 00);yl=s i n(xl);y 2=1+
2、s in(x 2);y 3=2+sin(x 3);x=xl;x 2;x 3;y=yi;y 2;y 3/;p 1 0 t(x,y,xl,yl 1)4 用不同标度在同一坐标内绘制曲线yl=0.2 e-0.5 xco s(4 n x)和 y2=2e_ 0.5x c os(n x)o程序如下:x=0:pi/100:2*pi;yl=0.2*exp(-0.5*x).*co s(4*p i*x);y2=2*exp(0.5*x).*cos(p i*x);p 1 otyy(x,yl,x,y 2);5 采用图形保持,在同一坐标内绘制曲线yl=O.2 e-0.5xcos(4五 x)和 y2=2 e-0.5 xcos
3、(汽 x)o程序如下:x=0:pi/10 0:2*pi;y l=0.2*ex p(-0.5*x).*cos(4*pi*x);P 1 ot(x,yl)ho 1 d ony2=2*exp(-0.5*x).*c os(pi*x);plot(x,y 2);hold off6 在同一坐标内,分别用不同线型和颜色绘制曲线y l=0.2e-0.5 xco s(4 J r x)和 y2=2 e-0.5x c o s(n x),标记两曲线交叉点。程序如下:x=li n sp a ce(0,2*pi,1 0 00);yl=0.2*e x p(-0.5*x).*c o s(4*pi*x);y2=2*exp(-0.5
4、*x).*c o s(p i*x);k=fin d(ab s(y 1 y2)1 e-2);x l=x(k);y3=0.2*e xp(0.5*x l).火cos(4*pi*xl);plot(x,yl,x,y2,k:,xl,y3;b p);7 在0 x t=0:0.01:2*pi;x=e xp(i*t);y=x;2*x;3*x;plot(y)grid o n;%加网格线box on;%加坐标边框axis e q u a l;%坐标轴采用等刻度?Erro r usin g=ge tInvalid hand 1 e obj e ct.E r r o r i n=ploty y local Up d a
5、tePo s itio n at 378n e wD e s t Pos=hgconv e rtuni t s(h Fig,newPos,g e t(axSo u rce,*Units),g e t(axDest,Un i ts),get(a x S o u r ce,P a rent);W a rn i n g:E r ror o c c urr e d whi 1 e eva 1 uatinglistener call b ack.In a x i s LocSet E qual at 3 61In axis at 13 5?Error u s in g=g etI nvalid han
6、d le o b j ec t.Error i n=p Iotyy 1 ocal U pda t ePos i tion at 3 7 8newD e s t Pos=h gc o nvertun i t s(hF i g,n e w P os,g e t(axSource,Uni t s*)g et(a x Dest,Units1),ge t(a x S o u r ce,Pare n t);W a r n ing:E r ror occu r r ed w hile e valuat i ng liste n ercall back.In axi s Loc S etEqu a 1 at
7、362In axis a t 13 5?Er r or u s in g=a x is a t 183U n k n ow n comm a nd option;9 用 fplot函数绘制f(x)=c os(tan(nx)的曲线。命令如下:fplot(cos(tan(pi*x),0,l,le-4)1 0.分别以条形图、阶梯图、杆图和填充图形式绘制曲线丫=2sin(x)o程序如下:x=0:pi/10:2*pi;y=2*s i n(x);s u b p lot(2,2,l);bar(x,y/g);t itl e(*bar(x,y,g);axis(0,7,2,2 );subp 1 ot(2,2,2)
8、;stairs(x,y/b);titleCs t airs(x,y,b);axis(0,7,-2,2);su b p 1 ot(2,2,3);st e m(x,y/k);t i 1 1 efs t em(x,y,k/);ax i s(0,7,-2,2);s ubp 1 ot(2,2,4);f ill(x,y,y);t it 1 e(fil 1 (x,y,y);ax i s(0,7,-2,2);s u b pl o t(2,2,1);ezp 1 ot(xA 2+yA2 9);a x is equalsubplot(2,2,2);e z p lot CxA3+yA3-5*x*y+115)subp
9、1 ot(2,2,3);ez p I o t(cos(tan(pi*x),0,1)subplot(2,2 4);ezplo t(8*c os(t),4*sqrt(2)*s in(t),0,2*pi)1 2 绘制了 p e aks函数曲面并且将它绕z 轴旋转。程序如下 X,Y,Z=peaks(30);su r f(X,Y,Z)axis(-3,3 ,-3,3,-1 0,1 0)ax i s off;s h a ding i nte r p;col o rmap(h o t);m=moviein(20);for i=l:2 0view(-3 7.5+24*(i-l),3 0)m(:,i)=getfr
10、ame;endm o vie(m,2);13.光照解决后的球面。程序如下:E x,y,z=sphe r e(2 0);s u b p lot(l,2,1);su r f(x,y,z);a xi s equ a I;lightd Posi,0,1,1);shad i ng in t e r p;hold o n;plot3(0,l,1 p);text(0,l,1;1 ight);s ubp l o t (1,2,2);surf(x,y,z);a xis eq u a I;lightCPosi*,1,O,U);s hadin g in t e rp;h old on;plo t 3(1,0,1/p);te xt(l,0,1;1 ig h t);