MATLAB动画演示程序汇总_第1页
MATLAB动画演示程序汇总_第2页
MATLAB动画演示程序汇总_第3页
MATLAB动画演示程序汇总_第4页
MATLAB动画演示程序汇总_第5页
已阅读5页,还剩33页未读 继续免费阅读

下载本文档

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

文档简介

1、MATLAB 动画演示程序汇总1.弹性蹦球演示程序figure(1);%定义函数axis(-5.1,5,-0.05,1.05);%绘制二维图形hold on;%保持当前图形及轴系所有的特性axis('off');%覆盖坐标刻度,并填充背景%通过填充绘出台阶及两边的挡板fill(4.12,4.22,4.22,4.12,-0.05,-0.05,1.05,1.05,'y');fill(-5,-3.2,-3.2,-5,-0.05,-0.05,0,0,'g');fill(-3.2,-2.8,-2.8,-3.2,-0.05,-0.05,0.2,0.2,

2、9;g');fill(-3.2,-1.4,-1.4,-3.2,0.2,0.2,0.25,0.25,'g');fill(-1.4,-1,-1,-1.4,0.2,0.2,0.45,0.45,'g');fill(-1.4,0.4,0.4,-1.4,0.45,0.45,0.5,0.5,'g');fill(0.4,0.8,0.8,0.4,0.45,0.45,0.7,0.7,'g');fill(0.4,2.0,2.0,0.4,0.7,0.7,0.75,0.75,'g');fill(2.0,2.3,2.3,2.0,-0.

3、05,-0.05,0.75,0.75,'g');fill(2.3,4.12,4.12,2.3,-0.05,-0.05,0,0,'g');%x2=line(-5,5,0.25,0.25,'color','g','linestyle','-', 'markersize',50)%设置台阶边框线,颜色,擦试方式%line(-5,5,0.5,0.5,'color','b','linestyle','-', 'marker

4、size',50)%设置球与地面接触面的颜色,擦试方式%line(-5,5,0.75,0.75,'color','b','linestyle','-', 'markersize',50)%设置球与地面接触面的颜色,擦试方式head=line(-5,1,'color','r','linestyle','.','erasemode','xor', 'markersize',60);%设置小球颜色,大小

5、,线条和擦试方式%body=line(-5,1,'color','b','linestyle','-','erasemode','none'); %描绘轨迹线%设置初始条件while 1t=4;dt=0.001;w=0;dw=0.001;w=0;%设置球弹起的初始位置%设置球弹起的高度while t<=4.12t=dt+t;if w<=1w=dw+w;elsew=-1;endy=(-w*w)+1;set(head,'xdata',t,'ydata',y);

6、%设置球的运动%set(body,'xdata',t,'ydata',y);%描绘轨迹线drawnow;end %结束程序w=0;%设置球弹起的初始位置%设置球弹起的高度while t>=2.11t=t-dt;if w<=1w=dw+w;elsew=-1;endy=(-w*w)+1;set(head,'xdata',t,'ydata',y);%设置球的运动%set(body,'xdata',t,'ydata',y);%描绘轨迹线drawnow;end %结束程序w=0;%设置球弹起的初始

7、位置%设置球弹起的高度while t>=1.11t=t-dt;if w<=1w=dw+w;elsew=-1;endy=(-w*w)/4+1;set(head,'xdata',t,'ydata',y);%设置球的运动%set(body,'xdata',t,'ydata',y);%描绘轨迹线drawnow;end %结束程序w=-0.71;%设置球弹起的初始位置%设置球弹起的高度while t>=-0.62t=t-dt;if w<=1w=dw+w;elsew=-1;endy=(-w*w)/2+1;set(hea

8、d,'xdata',t,'ydata',y);%设置球的运动%set(body,'xdata',t,'ydata',y);%描绘轨迹线drawnow;end %结束程序w=-0.71;%设置球弹起的初始位置%设置球弹起的高度while t>=-2.31t=t-dt;if w<=1w=dw+w;elsew=-1;endy=(-w*w)/2+0.75;set(head,'xdata',t,'ydata',y);%设置球的运动%set(body,'xdata',t,'y

9、data',y);%描绘轨迹线drawnow;end %结束程序w=-0.71;%设置球弹起的初始位置%设置球弹起的高度while t>=-4t=t-dt;if w<=1w=dw+w;elsew=-1;endy=(-w*w)/2+0.5;set(head,'xdata',t,'ydata',y);%设置球的运动%set(body,'xdata',t,'ydata',y);%描绘轨迹线drawnow;end %结束程序for i=0:0.01:200%设置延时y=i+2;if(y>199)endendend

10、2.嫦娥奔月演示程序figure('name','嫦娥一号与月亮、地球关系');%设置标题名字s1=0:.01:2*pi;hold on;axis equal;%建立坐标系axis off % 除掉Axesr1=10;%月亮到地球的平均距离r2=3;%嫦娥一号到月亮的平均距离w1=1;%设置月亮公转角速度w2=12%设置嫦娥一号绕月亮公转角速度t=0;%初始时刻为pausetime=.002;%设置暂停时间sita1=0;sita2=0;%设置开始它们都在水平线上set(gcf,'doublebuffer','on') %消除抖动

11、plot(-20,18,'color','r','marker','.','markersize',40);text(-17,18,'地球');%对地球进行标识p1=plot(-20,16,'color','b','marker','.','markersize',20);text(-17,16,'月亮');%对月亮进行标识p1=plot(-20,14,'color','w'

12、;,'marker','.','markersize',13);text(-17,14,'嫦娥一号');%对嫦娥一号进行标识plot(0,0,'color','r','marker','.','markersize',60);%画地球plot(r1*cos(s1),r1*sin(s1);%画月亮公转轨道set(gca,'xlim',-20 20,'ylim',-20 20);p1=plot(r1*cos(sita1),r

13、1*sin(sita1),'color','b','marker','.','markersize',30);%画月亮初始位置l1=plot(r1*cos(sita1)+r2*cos(s1),r1*sin(sita1)+r2*sin(s1);%画嫦娥一号绕月亮公转轨道p2x=r1*cos(sita1)+r2*cos(sita2);p2y=r1*sin(sita1)+r2*sin(sita2);p2=plot(p2x,p2y,'w','marker','.','

14、markersize',20);%画嫦娥一号的初始位置orbit=line('xdata',p2x,'ydata',p2y,'color','r');%画嫦娥一号的运动轨迹while 1set(p1,'xdata',r1*cos(sita1),'ydata',r1*sin(sita1);%设置月亮的运动过程set(l1,'xdata',r1*cos(sita1)+r2*cos(s1),'ydata',r1*sin(sita1)+r2*sin(s1);%设置嫦娥

15、一号绕月亮的公转轨道的运动过程ptempx=r1*cos(sita1)+r2*cos(sita2);ptempy=r1*sin(sita1)+r2*sin(sita2);set(p2,'xdata',ptempx,'ydata',ptempy);%设置嫦娥一号的运动过程p2x=p2x ptempx;p2y=p2y ptempy;set(orbit,'xdata',p2x,'ydata',p2y);%设置嫦娥一号运动轨迹的显示过程sita1=sita1+w1*pausetime;%月亮相对地球转过的角度sita2=sita2+w2*

16、pausetime;%嫦娥一号相对月亮转过的角度pause(pausetime); %暂停一会drawnowend3.曲柄连杆机构充气球动画演示程序hf=figure('name','打气筒吹气球');set(hf,'color','g');axis(-10,10,-4,4);hold onaxis off; %除掉坐标xa0=-2.5;%活塞左顶点坐标xa1=-1.8;%活塞右顶点坐标xb0=-2;%连杆左顶点坐标xb1=5;%连杆右顶点坐标x3=5.6;%转轮坐标y3=0;%转轮坐标x4=xb1;%设置连杆头的初始位置横坐标y

17、4=0;%设置连杆头的初始位置纵坐标x5=xa1;y5=0;x6=x3;%设置连轴初始横坐标y6=0;%设置连轴初始纵坐标a=0.7;b=0.7c=0.7a1=line(xa0;xa1,0;0,'color','m','linestyle','-','linewidth',20); %设置活塞a8=line(-2.7;2.3,0.3;0.3,'color','b','linestyle','-','linewidth',5);%设置打气

18、筒a9=line(-2.6;2.3,-0.3;-0.3,'color','b','linestyle','-','linewidth',5);%设置打气筒a10=line(-2.6;-2.6,-0.1;-0.37,'color','b','linestyle','-','linewidth',5);%设置打气筒a11=line(2.0;2.0,0.1;0.37,'color','b','linew

19、idth',5);%设置打气筒a12=line(2.0;2.0,-0.1;-0.37,'color','b','linewidth',5);%设置打气筒a13=line(-2.6;-2.6,0.1;0.37,'color','b','linestyle','-','linewidth',5);%设置打气筒a14=line(-2.7;-2.7,0.1;-0.1,'color','b','linestyle',

20、9;-','linewidth',9);%设置气筒嘴a16=line(-3.2;-3.2,0.1;-0.1,'color','r','linestyle','-','linewidth',25);%设置气筒嘴a2=line(xb0;xb1,0;0,'color','m','linewidth',5);%设置连杆a5=line(x5,y5,'color','black','linestyle',&#

21、39;.','markersize',25);%设置连杆活塞连接头a4=line(x4,y4,'color','black','linestyle','.','markersize',25);%设置连杆连接头a6=line(xb1;x3,0;0,'color','b','linestyle','-','linewidth',7);%设置连杆连接轴a7=line(x3,0,'color','

22、m','linestyle','.','markersize',50);%设置运动中心a3=line(x3,y3,'color' ,0.5 0.6 0.3,'linestyle','.','markersize',85);%设置手轮len1=6.8;%连杆长len2=0.7;%活塞长 r=1.3;%运动半径dd=0.01;d=-4;plot(d,0,'color','r','marker','.','ma

23、rkersize',10);pausetime=.0001s=0;ds=1;t=0;dt=0.015*pi;while t<=15.68t=t+dt;drawnow;lena1=sqrt(len1)2-(r*sin(2*t)2);%连杆在运动过程中横轴上的有效长度rr1=r*cos(t);%半径在运动过程中横轴上的有效长度xaa1=x3-sqrt(len12-(sin(2*t)*r)2)-(r*cos(2*t);%活塞在运动过程中的右顶点坐标位置xaa0=xaa1-2;%活塞在运动过程中的左顶点坐标位置x55=x3-cos(2*t)*r;%连杆在运动过程中横坐标位置y55=y3-

24、sin(2*t)*r*0.32;%连杆在运动过程中纵坐标位置set(a4,'xdata',x55,'ydata',y55);%设置连杆顶点运动set(a1,'xdata',xaa1-0.2;xaa1,'ydata',0;0);%设置活塞运动set(a2,'xdata',xaa1;x55,'ydata',0;y55);set(a5,'xdata',xaa1);%设置活塞与连杆连接头的运动set(a6,'xdata',x55;x3,'ydata',y55;

25、0);if (sign(y55-y3)>0)s=s+ds;d=d-dd;if s>200s=0;d=0;endset(gcf,'doublebuffer','on');%消除震动 plot(d,0,'color','r','marker','.','markersize',s);%画气球set(gcf,'doublebuffer','on') %消除抖动 pause(pausetime); %暂停一会drawnow;endendx=-8.0

26、 -7.0 -6.0 -5.5 -4.5 -3.5 -3.7 -3 -4 -5.5 -6.5 -7.5 -9.1 -7.3 ;y=-1.8 -1.2 -2.8 -1.5 -2.8 -0.5 -0.7 0.7 0.2 1.5 0.8 1.2 1.9 0.5;fill(x,y,'r'); text(-6,0,'pa','fontsize',22);4.打桩机动画演示程序clear; %清除工作区clc; %清除命令区figure('name','武工院打桩机); %设置标题axis (0 ,10,0,10); %建立坐标系ho

27、ld on;axis off; %除掉坐标text(3,9.8,'武工院打桩机','fontsize',20,'color','r');%画打桩机支架c1=line(1;5.5, 0.15;0.15,'color','k','linewidth',8);c2=line(1.7;5.2, 1.5;0.15,'color','k','linewidth',4);c3=line(1.8;5.2, 0.1;8,'color',&

28、#39;k','linewidth',4);c4=line(1.7;5.2, 1.5;8,'color','k','linewidth',2);c5=line(1.2;1.8, 0.5;0.5,'color','k','linewidth',13);fill(4.9,5.3,5.3,4.9,8.0,8.0,0.3,0.3,1,0.1,0.5);fill(4.4,4.6,5.6,5.8,5.6,4.6,8.4,8.3,8.3,8.4,8.0,8.0,1,0.1,0.5)%画打桩

29、机运动部分和水泥桩b1=line(8;8,1;6,'color','b','linewidth',6);b2=line(5.5,5.5,7.9,8,'color','k','linewidth',1);b3=line(5.3,5.55,7.9,7.9,'color','k','linewidth',3);b4=line(5.5,5.5,7.9,6.3,'color','k','linewidth',3);

30、b5=line(5.5,5.5,7,6.6,'color','k','linewidth',10);b6=line(5.5,5.5,6.6,6.3,'color','k','linewidth',12);pausetime=1.6; %设置暂停时间pause(pausetime);%吊装水泥桩s=0; ds=0.01;pausetime1=.002;while s<2.5 %水泥桩向左移动s=s+ds;set(b1,'xdata',8-s;8-s,'ydata'

31、,1;6);pause(pausetime1);endpausetime2=1;pause(pausetime2);s=0; ds=0.01;while s<1 %水泥桩向下移动s=s+ds;set(b1,'xdata',5.5;5.5,'ydata',1-s;6-s);pause(pausetime1);endpause(pausetime2);s=0; ds=0.01;while s<1.3 %打桩机运动部分下移与水泥桩顶端相接触s=s+ds;set(b2,'xdata',5.5;5.5,'ydata',7.9-s

32、,8);set(b3,'xdata',5.3;5.55,'ydata',7.9-s,7.9-s);set(b4,'xdata',5.5;5.5,'ydata',7.9-s,6.3-s);set(b5,'xdata',5.5;5.5,'ydata',7-s,6.6-s);set(b6,'xdata',5.5;5.5,'ydata',6.6-s,6.3-s);pause(pausetime1);end%打桩机开始打桩pausetime3=.4;pause(pausetim

33、e2);s=0; ds=0.06; %设定打桩进度while s<4a=0; da=0.01;pausetime4=.0002; while a<.4 %两个子循环设置打桩机铁锺上下反复运动a=a+da;set(b5,'xdata',5.5;5.5,'ydata',5.7-s+a,5.3-s+a);pause(pausetime4);enda=0; while a<.4a=a+da;set(b5,'xdata',5.5;5.5,'ydata',6.1-s-a,5.7-s-a);pause(pausetime4);

34、ends=s+ds;%打桩机运动部分与水泥桩同时向下移动set(b1,'xdata',5.5;5.5,'ydata',0;5-s);set(b2,'xdata',5.5;5.5,'ydata',6.6-s,8);set(b3,'xdata',5.3;5.55,'ydata',6.6-s,6.6-s);set(b4,'xdata',5.5;5.5,'ydata',6.6-s,5-s);set(b5,'xdata',5.5;5.5,'ydata&#

35、39;,5.7-s,5.3-s);set(b6,'xdata',5.5;5.5,'ydata',5.3-s,5-s);pause(pausetime3);end5.电路演示程序figure('name','基本电路的模拟');axis(-3,12,0,10);%建立坐标系hold on %保持当前图形的所有特性axis('off'); %关闭所有轴标注和控制%下面是画电池的过程fill(-1.5,-1.5,1.5,1.5,1,5,5,1,0.5,1,1);%确定坐标轴范围并填充fill(-0.5,-0.5,0.5,

36、0.5,5,5.5,5.5,5,0,0,0); %确定坐标轴范围并填充text(-0.5,1.5,'负极');%在坐标上标注说明文字text(-0.5,3,'电池'); %在坐标上标注说明文字text(-0.5,4.5,'正极'); %在坐标上标注说明文字%下面是画导电线路的过程plot(0;0,5.5;6.7,'color','r','linestyle','-','linewidth',4);%绘制二维图形线竖实心红色plot(0;4,6.7;6.7,'c

37、olor','r','linestyle','-','linewidth',4); %绘制二维图形线 实心红色为导线a=line(4;5,6.7;7.7,'color','b','linestyle','-','linewidth',4,'erasemode','xor');%画开关蓝色plot(5.2;9.2,6.7;6.7,'color','r','linestyle&

38、#39;,'-','linewidth',4);%绘制图导线为红色plot(9.2;9.2,6.7;3.7,'color','r','linestyle','-','linewidth',4);% 绘制图导线竖线为红线plot(9.2;9.7,3.7;3.7,'color','r','linestyle','-','linewidth',4); % 绘制图导线横线为红色plot(0;0,1;0,'

39、color','r','linestyle','-','linewidth',4);%如上画红色竖线plot(0;10,0;0,'color','r','linestyle','-','linewidth',4);%如上画横线plot(10;10,0;3,'color','r','linestyle','-','linewidth',4);%画竖线%下面是画灯泡的过

40、程fill(9.8,10.2,9.7,10.3,3,3,3.3,3.3,0 0 0);%确定填充范围plot(9.7,9.7,3.3,4.3,'color','b','linestyle','-','linewidth',0.5);%绘制灯泡外形线为蓝色plot(10.3,10.3,3.3,4.45,'color','b','linestyle','-','linewidth',0.5); %绘制灯泡外形线为蓝色%以下为绘圆x=9.7:

41、pi/50:10.3;%绘圆plot(x,4.3+0.1*sin(40*pi*(x-9.7),'color','b','linestyle','-','linewidth',0.5); %绘圆t=0:pi/60:2*pi; %绘圆plot(10+0.7*cos(t),4.3+0.6*sin(t),'color','b'); %绘圆%下面是箭头及注释的显示text(4.5,10,'电流运动方向'); %在坐标上标注说明文字line(4.5;6.6,9.4;9.4,

42、9;color','r','linestyle','-','linewidth',4,'erasemode','xor');%绘制箭头横线line(6.7,9.4,'color','b','linestyle','>','erasemode','xor','markersize',10);% %绘制箭头三角形pause(1);%下面是开关闭合的过程t=0;y=7.7;whil

43、e y>6.7 %电路总循环控制开关动作条件x=4+sqrt(2)*cos(pi/4*(1-t);y=6.7+sqrt(2)*sin(pi/4*(1-t);set(a,'xdata',4;x,'ydata',6.7;y);drawnow;t=t+0.1;end%下面是开关闭合后模拟大致电流流向的过程pause(1);light=line(10,4.3,'color','y','marker','.','markersize',40,'erasemode',

44、9;xor');%画灯丝发出的光:黄色%画电流的各部分h=line(1;1,5.2;5.6,'color','r','linestyle','-','linewidth',4,'erasemode','xor');g=line(1,5.7,'color','b','linestyle','','erasemode','xor','markersize',10);%给

45、循环初值t=0;m2=5.7;n=5.7;while n<6.3;%确定电流竖向循环范围m=1;n=0.05*t+5.7;set(h,'xdata',m;m,'ydata',n-0.5;n-0.1);set(g,'xdata',m,'ydata',n);t=t+0.01;drawnow;endt=0;while t<2;%在转角处的停顿时间m=1.2-0.2*cos(pi/4)*t);n=6.3+0.2*sin(pi/4)*t);set(h,'xdata',m-0.5;m-0.1,'ydata&

46、#39;,n;n);set(g,'xdata',m,'ydata',n);t=t+0.05;drawnow;endt=0;while t<0.5 %在转角后的停顿时间t=t+0.5;g=line(1.2,6.5,'color','b','linestyle','','markersize',10,'erasemode','xor');%绘制第二个箭头g=line(1.2,6.5,'color','b','l

47、inestyle','>','markersize',10,'erasemode','xor'); %绘制第二个箭头set(g,'xdata',1.2,'ydata',6.5);drawnow;endpause(0.5);t=0;while m<8 % 确定第二个箭头的循环范围m=1.1+0.05*t;n=6.5;set(g,'xdata',m+0.1,'ydata',6.5);set(h,'xdata',m-0.4;m,'

48、ydata',6.5;6.5);t=t+0.05;drawnow;endt=0;while t<2 %在转角后的停顿时间m=8.1+0.2*cos(pi/2-pi/4*t);n=6.3+0.2*sin(pi/2-pi/4*t);set(g,'xdata',m,'ydata',n);set(h,'xdata',m;m,'ydata',n+0.1;n+0.5);t=t+0.05;drawnow;endt=0;while t<0.5 %在转角后的停顿时间t=t+0.5;%绘制第三个箭头g=line(8.3,6.3,&

49、#39;color','b','linestyle','>','markersize',10,'erasemode','xor');g=line(8.3,6.3,'color','b','linestyle','v','markersize',10,'erasemode','xor');set(g,'xdata',8.3,'ydata',6.3

50、);drawnow;endpause(0.5);t=0;while n>1 %确定箭头的运动范围m=8.3;n=6.3-0.05*t;set(g,'xdata',m,'ydata',n);set(h,'xdata',m;m,'ydata',n+0.1;n+0.5);t=t+0.04;drawnow;endt=0;while t<2%箭头的起始时间m=8.1+0.2*cos(pi/4*t);n=1-0.2*sin(pi/4*t);set(g,'xdata',m,'ydata',n);set

51、(h,'xdata',m+0.1;m+0.5,'ydata',n;n);t=t+0.05;drawnow;endt=0;while t<0.5t=t+0.5;%绘制第四个箭头g=line(8.1,0.8,'color','b','linestyle','v','markersize',10,'erasemode','xor');g=line(8.1,0.8,'color','b','linestyle

52、9;,'<','markersize',10,'erasemode','xor');set(g,'xdata',8.1,'ydata',0.8);drawnow;endpause(0.5);t=0;while m>1.2 %箭头的运动范围m=8.1-0.05*t;n=0.8;set(g,'xdata',m,'ydata',n);set(h,'xdata',m+0.1;m+0.5,'ydata',n;n);t=t+0.04;d

53、rawnow;endt=0;while t<2 %停顿时间m=1.2-0.2*sin(pi/4*t);n=1+0.2*cos(pi/4*t);set(g,'xdata',m,'ydata',n);set(h,'xdata',m;m+0.5,'ydata',n-0.1;n-0.5);t=t+0.05;drawnow;endt=0;while t<0.5 %画第五个箭头t=t+0.5;g=line(1,1,'color','b','linestyle','<&#

54、39;,'markersize',10,'erasemode','xor');g=line(1,1,'color','b','linestyle','','markersize',10,'erasemode','xor');set(g,'xdata',1,'ydata',1);drawnow;endt=0;while n<6.3 %循环范围m=1;n=1+0.05*t;set(g,'xdat

55、a',m,'ydata',n);set(h,'xdata',m;m,'ydata',n-0.5;n-0.1);t=t+0.04;drawnow;end%下面是开关断开后的情况t=0;y=6.7;while y<7.7 %开关的断开x=4+sqrt(2)*cos(pi/4*t);y=6.7+sqrt(2)*sin(pi/4*t);set(a,'xdata',4;x,'ydata',6.7;y);drawnow;t=t+0.1;endpause(0.5);%开关延时作用nolight=line(10,4.

56、3,'color','y','marker','.','markersize',40,'erasemode','xor');6.电梯动画演示程序figure('name','自控电梯');axis(-2.0,15.0,-2.0,15.0)hold onfill(-2,15,15,-2,-2,-2,15,15,0.5,0.2,0.3);x1=8 8 10 10;y1=6 0 0 6;x2=10 10 12 12;text(-1,8,'上升'

57、;,'fontsize',10,'color','c');text(4,8,'下降','fontsize',10,'color','c');text(6,12.5,'控制电机','fontsize',10,'color','c');text(12.5,3,'电梯','fontsize',10,'color','c');text(5,4.5,'关闭&#

58、39;,'fontsize',10,'color','c');text(5,1.5,'打开','fontsize',10,'color','c'); l1=line(2;5.5,11;11,'color','c','linestyle','-','linewidth',2);l2=line(2;2,9;11,'color','c','linestyle',&

59、#39;-','linewidth',2);l3=line(1;1,7;9,'color','c','linestyle','-','linewidth',2);l4=line(3;3,7;9,'color','c','linestyle','-','linewidth',2);l5=line(1;3,9;9,'color','c','linestyle','

60、;-','linewidth',2);%绘制导线k1=line(2;1,6;7,'color','r','linestyle','-','linewidth',2);%单刀双掷开关k2=line(4;5,3;4,'color','b','linestyle','-','linewidth',2);%单刀双掷开关g1=line(7.7;8,3;3,'color','b','l

61、inestyle','-','linewidth',2);g2=line(7.7;7.7,3;4,'color','b','linestyle','-','linewidth',2);g3=line(7.4;7.7,2;4,'color','b','linestyle','-','linewidth',2);g4=line(7.4;7.4,2;4,'color','b

62、9;,'linestyle','-','linewidth',2);g5=line(7.1;7.4,2;4,'color','b','linestyle','-','linewidth',2);g6=line(7.1;7.1,2;4,'color','b','linestyle','-','linewidth',2);g7=line(6.8;7.1,2;4,'color',

63、'b','linestyle','-','linewidth',2);g8=line(6.8;6.8,2;4,'color','b','linestyle','-','linewidth',2);g9=line(6.5;6.8,2;4,'color','b','linestyle','-','linewidth',2);g10=line(6.5;6.5,2;3,'c

64、olor','b','linestyle','-','linewidth',2);g11=line(6.0;6.5,3;3,'color','b','linestyle','-','linewidth',2);g12=line(6;6,2;4,'color','c','linestyle','-','linewidth',2);g13=line(5;6,2;2,&#

65、39;color','c','linestyle','-','linewidth',2);g14=line(5;6,4;4,'color','c','linestyle','-','linewidth',2);%绘制电梯门伸缩控制开关door1=patch(x1,y1,0 1 1);door2=patch(x2,y1,0 1 1);%画电梯的两面门t=0:pi/100:2*pi;fill(6+0.5*sin(t),11+cos(t),0.7,0

66、.85,0.9);%电机左端fill(8.5+0.5*sin(t),11+cos(t),0.7,0.85,0.9);%电机右端e0=line(9;10,11;11,'color','r','linewidth',2);%e1=line(10;10,6;11,'color','b','linewidth',2);%连接电机中轴和电梯的线%画电机的表面(用八根不同颜色的线代替,每根之间相差pi/4)%为简便起见,初始条件下可将八根线分成两组放在电机的顶端和底端s1=line(6;8.5,12;12,&#

67、39;color','c','linestyle','-','linewidth',2);s2=line(6;8.5,10;10,'color','m','linestyle','-','linewidth',2);s3=line(6;8.5,12;12,'color','b','linestyle','-','linewidth',2);s4=line(6;8.5

68、,10;10,'color','w','linestyle','-','linewidth',2);s5=line(6;8.5,12;12,'color','k','linestyle','-','linewidth',2);s6=line(6;8.5,10;10,'color','g','linestyle','-','linewidth',2);s7=l

69、ine(6;8.5,12;12,'color','r','linestyle','-','linewidth',2);s8=line(6;8.5,10;10,'color','b','linestyle','-','linewidth',2);a=0; %设定电机运转的初始角度da=0.05;%设定电机正转的条件s=0; %设定门运动的初始条件ds=0.05;%设定门运动的周期while s<5 %条件表达式 (当0<s&l

70、t;5时,电机正转,门上升)a=a+da;xa1=6+abs(0.5*sin(a); %当线运动到电机背面时会覆盖电机左端,用abs可解决这一问题增强逼真感)xa2=8.5+0.5*sin(a);ya1=11+cos(a);ya2=11+cos(a);%设定s1的两端点坐标(s1是对应0的线)xb1=6+0.5*abs(sin(a+pi);xb2=8.5+0.5*sin(a+pi);yb1=11+cos(a+pi);yb2=11+cos(a+pi); %设定s2的两端点坐标(s2是对应pi的线)xc1=6+abs(0.5*sin(a+pi/2);xc2=8.5+0.5*sin(a+pi/2);

71、yc1=11+cos(a+pi/2);yc2=11+cos(a+pi/2);%设定s3的两端点坐标(s3是对应pi/2的线)xd1=6+0.5*abs(sin(a-pi/2);xd2=8.5+0.5*sin(a-pi/2);yd1=11+cos(a-pi/2);yd2=11+cos(a-pi/2);%设定s4的两端点坐标(s4是对应-pi/2的线)xe1=6+abs(0.5*sin(a+pi/4);xe2=8.5+0.5*sin(a+pi/4);ye1=11+cos(a+pi/4);ye2=11+cos(a+pi/4);%设定s5的两端点坐标(s5是对应pi/4的线)xf1=6+0.5*abs(sin(a+pi*3/4);xf2=8.5+0.5*sin(a+pi*3/4);yf1=11+cos(a+pi*3/4);yf2=11+cos(a+pi*3/4);%设定s6的两端点坐标(s6是对应pi*3/4的线)xg1=6+abs(0.5*sin(a-pi*3/4);xg2=8.5+0.5*sin(a-3*pi/4);yg1=11+cos(a-3*pi/4);yg2=11+cos(a-3*pi/4);%设定s7的两端点坐标(s7是对应-3*

温馨提示

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

评论

0/150

提交评论