资源描述:
《用matlab分析四杆机构》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、首先创建函数FoutBarPosition,函数fsolve通过他确定。functiont=fourbarposition(th,th2,L2,L3,L4,L1)t=[L2*cos(th2)+L3*cos(th(1))-L4*cos(th(2))-L1L2*sin(th2)+L3*sin(th(1))-L4*sin(th(2))];主程序如下:disp*******平面四杆机构的运动分析*******L1=304.8;L2=101.6;L3=254.0;L4=177.8;%给定己知量,各杆长L1丄2丄3丄4th2=[0:1/6:2]*pi;%曲柄输入角度从0至360度,步
2、长为pi/6th34=zeros(length(th2),2);%建立一个N行2列的零矩阵,第一列存放options=optimset('displayToff);%9_3,第二列存放0_3form=1:length(th2)%建立for循环,求解0_3,0_4th34(m,:)=fsolve('fourbarposition,,[11],...%调用fsove函数求解关丁8_3,0_4options,th2(m),L2,L3,L4,L1);%的非线性超越方程,结果保存在th34中endy=L2*sin(th2)+L3*sin(th34(:,1)*);%连杆3的D端点丫坐
3、标值x=L2*cos(th2)+L3*cos(th34(:,iy);%连杆3的D端点X坐标值xx=[L2*cos(th2)];%连杆3的C端点X坐标侑yy=[L2*sin(th2)];%连杆3的C端点丫坐标值figure(1)plot([x;xx],[y;yy]/k[0L1],[00],...%绘制连杆3的几个位置点'k-^.x.y/ko^xx.yy/ks*)title。连杆3的几个位置点')xlabef水平方向')ylabel(唾直方向')axisequal%XY坐标均衡th2=[0:2/72:2]*pi;%重新细分曲柄输入角度8_2,步长为5度th34=zeros(
4、length(th2),2);options二optimset('displayToff);form=1:length(th2)th34(m,:)=fsolve('fourbarposition,,[11],...options,th2(m),L2,L3,L4,L1);endfigure(2)plot(th2*180/pi,th34(:,1),th2*180/pi,th34(:,2))%绘制连杆3的角位移关于曲柄2的角位移图plot(th2*180/pi,th34(:,1)*180/pi,...th2*180/pi,th34(:,2)*180/pi)%绘制摇杆4的角位移关
5、于曲柄2的角位移图axis([O3600170])%确定XY边界值grid%图形加网格xlabel('主动件转角theta_2(度)')ylabelC从动件角位移(度)')title。角位移线图)text(120,120/}§杆4角位移?text(150,40,‘连杆3角位移')w2=250;%设定曲柄角速度fori=1:length(th2)A=[-L3*sin(th34(i,1))L4*sin(th34(i,2));...L3*cos(th34(i,1))-L4*cos(th34(i,2))];B=[w2*L2*sin(th2(i));-w2*L2*cos(th2(
6、i))];w=inv(A)*B;w3(i)=w(1);w4(i)=w(2);endfigure(3)plot(th2*180/pi,w3,th2*180/pi,w4);%绘制角速度线图axis([0360-175200])text(50,160;摇杆4角速度(omega_4)1)text(220,130;连杆3角速度(omega_3)1)gridxlabef主动件转角theta_2(度)')ylabef从动件角速度(radcdotsA{-1})*)title。角速度线图Jfori=1:length(th2)C=[-L3*sin(th34(i,1))L4*sin(t
7、h34(i,2));...L3*cos(th34(i,1))-L4*cos(th34(i,2))];D=[w2A2*L2*cos(th2(i))+w3(i)A2*L3*cos(th34(i,1))-w4(i)A2*L4*cos(th34(i,2));...w2A2*L2*sin(th2(i))+w3(i)A2*L3*sin(th34(i,1))-w4(i)A2*L4*sin(th34(i,2))];a=inv(C)*D;a3(i)=a(1);a4(i)=a(2);endfigure(4)plot(th2*180/pi,a3,t