資源描述:
《用matlab分析四桿機(jī)構(gòu)》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在工程資料-天天文庫。
1、首先創(chuàng)建函數(shù)FoutBarPosition,函數(shù)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*******平面四桿機(jī)構(gòu)的運(yùn)動(dòng)分析*******L1=304.8;L2=101.6;L3=254.0;L4=177.8;%給定己知量,各桿長(zhǎng)L1丄2丄3丄4th2=[0:1/6:2]*pi;%曲柄輸入角度從0至360度,步
2、長(zhǎng)為pi/6th34=zeros(length(th2),2);%建立一個(gè)N行2列的零矩陣,第一列存放options=optimset('displayToff);%9_3,第二列存放0_3form=1:length(th2)%建立for循環(huán),求解0_3,0_4th34(m,:)=fsolve('fourbarposition,,[11],...%調(diào)用fsove函數(shù)求解關(guān)丁8_3,0_4options,th2(m),L2,L3,L4,L1);%的非線性超越方程,結(jié)果保存在th34中endy=L2*sin(th2)+L3*sin(th34(:,1)*);%連桿3的D端點(diǎn)丫坐
3、標(biāo)值x=L2*cos(th2)+L3*cos(th34(:,iy);%連桿3的D端點(diǎn)X坐標(biāo)值xx=[L2*cos(th2)];%連桿3的C端點(diǎn)X坐標(biāo)侑yy=[L2*sin(th2)];%連桿3的C端點(diǎn)丫坐標(biāo)值figure(1)plot([x;xx],[y;yy]/k[0L1],[00],...%繪制連桿3的幾個(gè)位置點(diǎn)'k-^.x.y/ko^xx.yy/ks*)title。連桿3的幾個(gè)位置點(diǎn)')xlabef水平方向')ylabel(唾直方向')axisequal%XY坐標(biāo)均衡th2=[0:2/72:2]*pi;%重新細(xì)分曲柄輸入角度8_2,步長(zhǎng)為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的角位移關(guān)于曲柄2的角位移圖plot(th2*180/pi,th34(:,1)*180/pi,...th2*180/pi,th34(:,2)*180/pi)%繪制搖桿4的角位移關(guān)
5、于曲柄2的角位移圖axis([O3600170])%確定XY邊界值grid%圖形加網(wǎng)格xlabel('主動(dòng)件轉(zhuǎn)角theta_2(度)')ylabelC從動(dòng)件角位移(度)')title。角位移線圖)text(120,120/}§桿4角位移?text(150,40,‘連桿3角位移')w2=250;%設(shè)定曲柄角速度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主動(dòng)件轉(zhuǎn)角theta_2(度)')ylabef從動(dòng)件角速度(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