您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 其它文档 > 基于MATLAB曲柄滑块机构运动仿真报告
...计算机仿真技术matlab报告曲柄滑块机构...目录一、基于GUI的曲柄滑块机构运动仿真二、基于simulink的曲柄滑块机构运动仿真...曲柄滑块机构1.题目描述题目:对如图1所示的曲柄滑块机构的运动过程进行仿真,并用动画的方式显示曲柄滑块机构的运动过程,位移曲线、速度曲线和加速度曲线。图中,AB长R2,BC长R3mm,A点为坐标原点。图1曲柄滑块机构示意图2.实现方法利用GUI界面设计来对曲柄滑块机构的运动过程进行仿真,并用动画的方式显示曲柄滑块机构的运动过程。3.界面设计1.Gui设计1)新建GUI:菜单-新建-gui,并保存为test5...2)界面设计:拖拽左侧图标到绘图区,创建GUI界面拖拽左侧图标值绘图区...设置如下的按钮最终的仿真界面如图所示...3)代码添加:进入代码界面...4.代码编程%模型求解a1=str2double(get(handles.edit1,'String'));a2=str2double(get(handles.edit2,'String'));a3=str2double(get(handles.edit3,'String'));a4=str2double(get(handles.edit4,'String'));a5=str2double(get(handles.edit5,'String'));a=a1*((1-cos(a4*a5))+0.25*(a1/a2)*(1-cos(2*a4*a5)));set(handles.edit6,'String',a);a0=(a4*a1)*(sin(a4*a5)+0.5*(a1/a2)*sin(2*a4*a5));set(handles.edit7,'String',a0);a6=(a4*a4*a1)*(cos(a4*a5)+(a1/a2)*cos(a4*a5));set(handles.edit8,'String',a6);%绘制位移、速度、加速度曲线axes(handles.axes3);r1=str2double(get(handles.edit1,'String'));r2=str2double(get(handles.edit2,'String'));omiga1=str2double(get(handles.edit4,'String'));x11=1:720;fori=1:720x1(i)=i*pi/180;%sin(x2(i)=r1/r2*sin(x1(i));x2(i)=asin(-r1/r2*sin(x1(i)));x22(i)=x2(i)*180/pi;r3(i)=r1*cos(x1(i))+r2*cos(x2(i));B=[-r1*omiga1*sin(x1(i));r1*omiga1*cos(x1(i))];A=[r2*sin(x2(i))1;-r2*cos(x2(i))0];X=inv(A)*B;omiga2(i)=X(1,1);v3(i)=X(2,1);endplot(x11/60,0.5*r1*sin(x1));xlabel('ʱ¼äÖát/sec')ylabel('Á¬¸ËÖÊÐÄÔÚYÖáÉϵÄλÖÃ/mm')figure(2)...plot(x11/60,r3);title('λÒÆÏßͼ')gridonholdoff;xlabel('ʱ¼ät/sec')ylabel('»¬¿éλÒÆr3/mm')figure(3)plot(x11/60,omiga2);title('Á¬¸Ë½ÇËÙ¶È')gridonholdoff;xlabel('ʱ¼ät/sec')ylabel('Á¬¸Ë½ÇËÙ¶Èomiga2/rad/sec')figure(4)plot(x11/60,v3*pi/180);title('»¬¿éËÙ¶È')gridonholdoff;xlabel('ʱ¼ät/sec')ylabel('»¬¿éËÙ¶Èv3/mm/sec')%绘制表格axes(handles.axes3);gridonaxes(handles.axes1);gridon%制作动画axes(handles.axes1);hf=figure('name','Çú±ú»¬¿é»ú¹¹');set(hf,'color','r');holdonaxis([-6,6,-4,4]);gridonaxis('off');xa0=-5;%»îÈû×󶥵ã×ø±êxa1=-2.5;%»îÈûÓÒ¶¥µã×ø±êxb0=-2.5;%Á¬¸Ë×󶥵ã×ø±êxb1=2.2;%Á¬¸ËÓÒ¶¥µã×ø±êx3=3.5;%תÂÖ×ø±ê...y3=0;%תÂÖ×ø±êx4=xb1;%ÉèÖÃÁ¬¸ËÍ·µÄ³õʼλÖúá×ø±êy4=0;%ÉèÖÃÁ¬¸ËÍ·µÄ³õʼλÖÃ×Ý×ø±êx5=xa1;y5=0;x6=x3;%ÉèÖÃÁ¬Öá³õʼºá×ø±êy6=0;%ÉèÖÃÁ¬Öá³õʼ×Ý×ø±êa=0.7;b=0.7c=0.7a1=line([xa0;xa1],[0;0],'color','b','linestyle','-','linewidth',40);%ÉèÖûîÈûa3=line(x3,y3,'color',[0.50.60.3],'linestyle','.','markersize',300);%ÉèÖÃתÂÖa2=line([xb0;xb1],[0;0],'color','black','linewidth',10);%ÉèÖÃÁ¬¸Ëa5=line(x5,y5,'color','black','linestyle','.','markersize',40);%ÉèÖÃÁ¬¸Ë»îÈûÁ¬½ÓÍ·a4=line(x4,y4,'color','black','linestyle','.','markersize',50);%ÉèÖÃÁ¬¸ËÁ¬½ÓÍ·a6=line([xb1;x3],[0;0],'color','black','linestyle','-','linewidth',10);a7=line(x3,0,'color','black','linestyle','.','markersize',50);%ÉèÖÃÔ˶¯ÖÐÐÄa8=line([-5.1;-0.2],[0.7;0.7],'color','y','linestyle','-','linewidth',5);%ÉèÖÃÆû¸×±Úa9=line([-5.1;-0.2],[-0.72;-0.72],'color','y','linestyle','-','linewidth',5);%ÉèÖÃÆû¸×±Úa10=line([-5.1;-5.1],[-0.8;0.75],'color','y','linestyle','-','linewidth',5);%ÉèÖÃÆû¸×±Úa11=fill([-5,-5,-5,-5],[0.61,0.61,-0.61,-0.61],[a,b,c]);%ÉèÖÃÆû¸×ÆøÌålen1=4.8;%Á¬¸Ë³¤len2=2.5;%»îÈû³¤r=1.3;%Ô˶¯°ë¾¶dt=0.015*pi;t=0;while1t=t+dt;ift2*pit=0;end...lena1=sqrt((len1)^2-(r*sin(t))^2);%Á¬¸ËÔÚÔ˶¯¹ý³ÌÖкáÖáÉϵÄÓÐЧ³¤¶Èrr1=r*cos(t);%°ë¾¶ÔÚÔ˶¯¹ý³ÌÖкáÖáÉϵÄÓÐЧ³¤¶Èxaa1=x3-sqrt(len1^2-(sin(t)*r)^2)-(r*cos(t));%»îÈûÔÚÔ˶¯¹ý³ÌÖеÄÓÒ¶¥µã×ø±êλÖÃxaa0=xaa1-2.5;%%»îÈûÔÚÔ˶¯¹ý³ÌÖеÄ×󶥵ã×ø±êλÖÃx55=x3-cos(t)*r;%Á¬¸ËÔÚÔ˶¯¹ý³ÌÖкá×ø±êλÖÃy55=y3-sin(t)*r;%Á¬¸ËÔÚÔ˶¯¹ý³ÌÖÐ×Ý×ø±êλÖÃset(a4,'xdata',x55,'ydata',y55);%ÉèÖÃÁ¬¸Ë¶¥µãÔ˶¯set(a1,'xdata',[xaa1-2.5;xaa1],'ydata',[0;0]);%ÉèÖûîÈûÔ˶¯set(a2,'xdata',[xaa1;x55],'ydata',[0;y55]);set(a5,'xdata',xaa1);%ÉèÖûîÈûÓëÁ¬¸ËÁ¬½ÓÍ·µÄÔ˶¯set(a6,'xdata',[x55;x3],'ydata',[y55;0]);set(a11,'xdata',[-5,xaa0,xaa0,-5]);%ÉèÖÃÆøÌåµÄÌî³äset(gcf,'doublebuffer','on');%Ïû³ýÕð¶¯drawnow;end5.结果(1)对它的结构参数进行设置,如下图所示...点击计算按钮动画,结果如下图所示...点击表格对图形进行画表格处理点击绘图,即可得到位移、速度、加速度曲线,如下图所示......二、基于simulink的曲柄滑块机构运动仿真(1)运用矢量求解法求解...(2)绘制速度接线图,如下图所示:...运动仿真结果如下图:(3)绘制加速度接线图,如下图所示:...运行结果如图所示:
本文标题:基于MATLAB曲柄滑块机构运动仿真报告
链接地址:https://www.777doc.com/doc-4466624 .html