机械原理各机构运动学分析说明.docx

上传人:b****5 文档编号:28949970 上传时间:2023-07-20 格式:DOCX 页数:17 大小:395.40KB
下载 相关 举报
机械原理各机构运动学分析说明.docx_第1页
第1页 / 共17页
机械原理各机构运动学分析说明.docx_第2页
第2页 / 共17页
机械原理各机构运动学分析说明.docx_第3页
第3页 / 共17页
机械原理各机构运动学分析说明.docx_第4页
第4页 / 共17页
机械原理各机构运动学分析说明.docx_第5页
第5页 / 共17页
点击查看更多>>
下载资源
资源描述

机械原理各机构运动学分析说明.docx

《机械原理各机构运动学分析说明.docx》由会员分享,可在线阅读,更多相关《机械原理各机构运动学分析说明.docx(17页珍藏版)》请在冰豆网上搜索。

机械原理各机构运动学分析说明.docx

机械原理各机构运动学分析说明

基于matlab的《机械原理》杆件运动分析

2012-6-5

目录

一.概述2

二.程序编制过程2

1.铰链四杆机构2

2.倒杆机构5

3.曲柄滑块机构8

4.popupmenu设计10

5.保存11

三.总结12

一.概述

大二时学习《机械原理》课程的时候,杆件的运动分析用的是作图法,不经效率较低,而且不精确。

用解析法求数学表达式繁杂,易出错。

为了解决以上问题,我用matlab做了一个分析铰链四杆机构、曲柄滑块机构和倒杆机构的分析。

只要输入数据,便可以分别做出各个杆件或滑块的位移、速度、加速度图像,如果需要的话可对生成图像分别保存,简单实用。

二.程序编制过程

1.铰链四杆机构

基本功能:

用if语句,如果符合杆长条件则按要求计算,如果不符合,则输出相应提示信息。

程序段:

l1=str2num(get(handles.edit1,'string'));

l2=str2num(get(handles.edit2,'string'));

l3=str2num(get(handles.edit3,'string'));

l4=str2num(get(handles.edit4,'string'));

w1=str2num(get(handles.edit5,'string'));

th1=0:

0.1:

2*pi;

if((l1+l2<=l3+l4)&&(l1+l3<=l2+l4)&&(l1+l4<=l2+l3)&&(l1

set(handles.edit6,'visible','on')

set(handles.edit6,'string','杆长符合条件')

A=l4-l1*cos(th1);

B=-l1*sin(th1);

C=(A.*A+B.*B+l3.^2-l2.^2)/(2*l3);

th3=2*atan((B+sqrt(A.*A+B.*B-C.*C))./(A-C));%角度分析,杆3转过的角度

th2=atan(B+l2*sin(th3)./(A+cos(th3)));%杆2转过的角度

w3=w1*l1*sin(th1-th2)./(l3*sin(th3-th2));%速度分析,杆3角速度

w2=-w1*l1*sin(th1-th3)./(l2*sin(th2-th3));%杆2角速度

a3=(l2*w2.^2+l1*w1.^2.*cos(th1-th2)-l3*w3.^2.*cos(th3-th2))./(l3*sin(th3-th2));%加速度分析,杆3角加速度

a2=(l3*w3.^2-l1*w1.^2.*cos(th1-th3)-l2*w2.^2.*cos(th2-th3))./(l2*sin(th2-th3));%杆2角加速度

plot(handles.axes2,th1,th2);

title(handles.axes2,'杆2角位移变化曲线')

xlabel(handles.axes2,'th1');

ylabel(handles.axes2,'角位移rad');

axes(handles.axes2);

gridon;

plot(handles.axes4,th1,th3,'b')

title(handles.axes4,'杆3角位移变化曲线')

xlabel(handles.axes4,'th1');

ylabel(handles.axes4,'角位移rad');

axes(handles.axes4);

gridon;

plot(handles.axes6,th1,w2,'m')

title(handles.axes6,'杆3角速度变化曲线')

xlabel(handles.axes6,'th1');

ylabel(handles.axes6,'角速度rad/s');

axes(handles.axes6);

gridon;

plot(handles.axes7,th1,w3,'k')

title(handles.axes7,'杆2角速度变化曲线')

xlabel(handles.axes7,'th1');

ylabel(handles.axes7,'角速度rad/s');

axes(handles.axes7);

gridon;

plot(handles.axes8,th1,a2,'b')

title(handles.axes8,'杆2角加速度变化曲线')

xlabel(handles.axes8,'th1');

ylabel(handles.axes8,'角加速度rad/s^2');

axes(handles.axes8);

gridon;

plot(handles.axes9,th1,a3,'b')

title(handles.axes9,'杆3角加速度变化曲线')

xlabel(handles.axes9,'th1');

ylabel(handles.axes9,'角加速度rad/s^2');

axes(handles.axes9);

gridon;

else

set(handles.edit6,'visible','on')

set(handles.edit6,'string','不符合杆长条件或整转副条件,请重新输入')

message='不符合杆长条件或整转副条件,请重新输入';

icon='error';

h=msgbox(message,'出错',icon)

y=wavread('ding.wav');

sound(y)

end

在这里面最容易出错的就是在数如表达式的时候,需要在不同的计算函数之间加点如“:

th3=2*atan((B+sqrt(A.*A+B.*B-C.*C))./(A-C));%角度分析,杆3转过的角度,

不仅在相乘之间加,而且在相除时也不要加入,不然会出错。

符合杆长条件,效果如下:

不符合杆长条件时(20+40>30+25):

2.倒杆机构

这些都是一些简单的程序。

程序段:

l1=str2num(get(handles.edit1,'string'));

l2=str2num(get(handles.edit2,'string'));

w1=str2num(get(handles.edit5,'string'));

th1=0:

0.1:

2*pi;

th2=asin(-l1*sin(th1)/l2);

%位置分析

th2=asin(-l1*sin(th1)./l2);%杆2的角位移

xc=l1*cos(th1)+l2*cos(th2);%滑块的位置变化

%速度分析

vc=-l1*w1*sin(th1-th2)./cos(th2);%滑块c的速度

w2=-l1*w1*cos(th1)./(l2*cos(th2));%杆2的角速度

%加速度分析

ac=-(l1*w1.*w1.*cos(th1-th2)+l2*w2.*w2)./(l2*cos(th2));%滑块c的加速度

a2=(l1*w1.*w1.*sin(th1)+l2*w2.*w2.*sin(th2))./(l2*cos(th2));%杆2的角加速度

plot(handles.axes2,th1,th2);

title(handles.axes2,'杆2角位移变化曲线')

xlabel(handles.axes2,'th1');

ylabel(handles.axes2,'角位移rad');

axes(handles.axes2);

gridon;

plot(handles.axes4,th1,xc);

title(handles.axes4,'滑块的位置变化')

xlabel(handles.axes4,'th1');

ylabel(handles.axes4,'位移');

axes(handles.axes4);

gridon;

plot(handles.axes6,th1,vc);

title(handles.axes6,'滑块c的速度曲线')

xlabel(handles.axes6,'th1');

ylabel(handles.axes6,'速度');

axes(handles.axes6);

gridon;

plot(handles.axes7,th1,w2);

title(handles.axes7,'杆2的角速度曲线')

xlabel(handles.axes7,'th1');

ylabel(handles.axes7,'杆2角速度');

axes(handles.axes7);

gridon;

plot(handles.axes8,th1,ac);

title(handles.axes8,'滑块c的加速度')

xlabel(handles.axes8,'th1');

ylabel(handles.axes8,'加速度');

axes(handles.axes8);

gridon;

plot(handles.axes9,th1,a2);

title(handles.axes9,'杆2的角加速度')

xlabel(handles.axes9,'th1');

ylabel(handles.axes9,'加速度');

axes(handles.axes9);

gridon;

elseifz1==2

l1=str2num(get(handles.edit1,'string'));

l4=str2num(get(handles.edit4,'string'));

w1=str2num(get(handles.edit5,'string'));

th1=0:

0.1:

2*pi;

%位置分析

th3=atan((l1*sin(th1)+l4)./(l1*cos(th1)));%杆3的位置变化

s=l1*cos(th1)./cos(th3);%滑块2在杆3上的位移变化

%速度分析

vb2b3=-l1*w1*sin(th1-th3);%滑块2相对于杆3的速度

w3=l1*w1*cos(th1-th3)./s;%杆3的角速度

%加速度分析

ab2b3=s.*w3.^2-l1*cos(th1-th3)*w1.^2;%滑块2相对于杆3的加速度

a3=-(2*vb2b3.*w3+l1*w1.^2.*sin(th1-th3))./s;%杆3的角加速度

plot(handles.axes2,th1,th3);

title(handles.axes2,'杆3角位移变化曲线')

xlabel(handles.axes2,'th1');

ylabel(handles.axes2,'角位移rad');

axes(handles.axes2);

gridon;

plot(handles.axes4,th1,s);

title(handles.axes4,'滑块2在杆3上的位移变化')

xlabel(handles.axes4,'th1');

ylabel(handles.axes4,'位移');

axes(handles.axes4);

gridon;

plot(handles.axes6,th1,vb2b3);

title(handles.axes6,'滑块2相对于杆3的速度')

xlabel(handles.axes6,'th1');

ylabel(handles.axes6,'速度');

axes(handles.axes6);

gridon;

plot(handles.axes7,th1,w3);

title(handles.axes7,'杆3的角速度曲线')

xlabel(handles.axes7,'th1');

ylabel(handles.axes7,'杆3角速度');

axes(handles.axes7);

gridon;

plot(handles.axes8,th1,ab2b3);

title(handles.axes8,'滑块2相对于杆3的加速度')

xlabel(handles.axes8,'th1');

ylabel(handles.axes8,'加速度');

axes(handles.axes8);

gridon;

plot(handles.axes9,th1,a3);

title(handles.axes9,'杆2的角加速度')

xlabel(handles.axes9,'th1');

ylabel(handles.axes9,'加速度');

axes(handles.axes9);

gridon;

效果如图:

3.曲柄滑块机构

程序:

l1=str2num(get(handles.edit1,'string'));

l4=str2num(get(handles.edit4,'string'));

w1=str2num(get(handles.edit5,'string'));

th1=0:

0.1:

2*pi;

%位置分析

th3=atan((l1*sin(th1)+l4)./(l1*cos(th1)));%杆3的位置变化

s=l1*cos(th1)./cos(th3);%滑块2在杆3上的位移变化

%速度分析

vb2b3=-l1*w1*sin(th1-th3);%滑块2相对于杆3的速度

w3=l1*w1*cos(th1-th3)./s;%杆3的角速度

%加速度分析

ab2b3=s.*w3.^2-l1*cos(th1-th3)*w1.^2;%滑块2相对于杆3的加速度

a3=-(2*vb2b3.*w3+l1*w1.^2.*sin(th1-th3))./s;%杆3的角加速度

plot(handles.axes2,th1,th3);

title(handles.axes2,'杆3角位移变化曲线')

xlabel(handles.axes2,'th1');

ylabel(handles.axes2,'角位移rad');

axes(handles.axes2);

gridon;

plot(handles.axes4,th1,s);

title(handles.axes4,'滑块2在杆3上的位移变化')

xlabel(handles.axes4,'th1');

ylabel(handles.axes4,'位移');

axes(handles.axes4);

gridon;

plot(handles.axes6,th1,vb2b3);

title(handles.axes6,'滑块2相对于杆3的速度')

xlabel(handles.axes6,'th1');

ylabel(handles.axes6,'速度');

axes(handles.axes6);

gridon;

plot(handles.axes7,th1,w3);

title(handles.axes7,'杆3的角速度曲线')

xlabel(handles.axes7,'th1');

ylabel(handles.axes7,'杆3角速度');

axes(handles.axes7);

gridon;

plot(handles.axes8,th1,ab2b3);

title(handles.axes8,'滑块2相对于杆3的加速度')

xlabel(handles.axes8,'th1');

ylabel(handles.axes8,'加速度');

axes(handles.axes8);

gridon;

plot(handles.axes9,th1,a3);

title(handles.axes9,'杆2的角加速度')

xlabel(handles.axes9,'th1');

ylabel(handles.axes9,'加速度');

axes(handles.axes9);

gridon;

效果如下:

4.popupmenu设计

当选中不同的杆件时,见面发生对应变化,这里面界面button比较多,不同的杆件需要不同edittext的数值,所以容易混乱。

用if语句编制如下:

z1=get(handles.popupmenu1,'value');

ifz1==1

tu1=imread('jiaolian.png');

axes('position',[0.01,0.4,0.2,0.3]);%显示图像

image(tu1);

axisoff

set(handles.edit7,'string','铰链四杆机构运动分析')

set(handles.gan3,'visible','on')

set(handles.gan2,'visible','on')

set(handles.gan4,'visible','on')

set(handles.edit3,'visible','on')

set(handles.edit2,'visible','on')

set(handles.edit4,'visible','on')

set(handles.edit6,'visible','on')

elseifz1==2

tu3=imread('qubingyaogan.jpg');

axes('position',[0.01,0.4,0.2,0.3]);

image(tu3);

axisoff

set(handles.gan3,'visible','off')

set(handles.gan4,'visible','on')

set(handles.gan2,'visible','off')

set(handles.edit4,'visible','on')

set(handles.edit3,'visible','off')

set(handles.edit2,'visible','off')

set(handles.edit6,'visible','off')

set(handles.edit7,'string','倒杆机构运动分析')

else

z1==3

tu2=imread('qubinghuakaui.jpg');

axes('position',[0.01,0.4,0.2,0.3]);

image(tu2);

axisoff

set(handles.gan3,'visible','off')

set(handles.gan4,'visible','off')

set(handles.gan2,'visible','on')

set(handles.edit2,'visible','on')

set(handles.edit3,'visible','off')

set(handles.edit4,'visible','off')

set(handles.edit6,'visible','off')

set(handles.edit7,'string','曲柄滑块机构运动分析')

end

5.保存

生成了图像,对其保存:

[FileName,PathName,filterindex]=uiputfile({'*.jpg','JPEG(*.jpg)';...

'*.bmp','Bitmap(*.bmp)';...

'*.gif','GIF(*.gif)';...

'*.*','AllFiles(*.*)'},...

'SavePicture','Untitled');

iffilterindex

h=getframe(handles.axes9);

imwrite(h.cdata,[PathName,FileName]);

end

三.总结

做了这个大作业之后,感觉matlab这个软件功能十分强大,自己不过只用了它的冰山一角,而且大部分都是用的课本上简单的基础命令。

在调试程序的过程中,虽然改正一次次的错误很辛苦,但自己从这些错误中学到了这些命令的用法,也看到了matlab的灵活性、实用性。

其次,这也是对以前专业基础课的一个升华,学到了知识要综合利用,这样才能使知识得到交融,自己对它们也会有新的认识,从而”温故而知新“,获得意想不到的效果。

今后的学习生活中,遇到一些实际问题完全可以用matlab编一些程序来解决,尤其是涉及数值计算和图像处理。

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 初中教育 > 理化生

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1