Matlab在机械设计中的应用大作业.pdf
Matlab在机械设计中的应用 大作业1、试用解析综合法设计一个曲柄摇杆机构。已知机构行程速度变化系数k1.25,摇杆 CD 的长度l3250mm,摆角30,要求机构的最小传动角min40。确定曲柄摇杆机构各构件杆长调用函数的编制:function f=funct(x)k=1。25;theta=pi*(k 1)/(k+1);yg=250;pis=pi/6 gamin=2 pi/9f1=(x(2)+x(1))2+(x(2)-x(1)2-2*(x(2)+x(1))(x(2)x(1))cos(theta)(2yg*sin(pis/2))2;f2=yg2+x(3)2 2*yg x(3)cos(x(4)-(x(2)x(1))2;f3=yg2+x(3)2 2yg*x(3)cos(x(4)+pis)(x(2)+x(1))2;f4=yg2+x(2)2-2*yg*x(2)cos(gamin)(x(3)x(1)2;f=f1;f2;f3;f4;主函数:x0=50 120 200 0.5;k=1。25;theta=pi*(k-1)/(k+1);yg=250;gamin=2*pi/9;x=fsolve(funct,x0)求解结果:Equation solved.fsolve completed because the vector of funct values is near zeroas measured by the default value of the funct tolerance,andthe problem appears regular as measured by the gradient。stopping criteria detailsx=62。9934 105。9045 245.0702 0。17242、四连杆机构如图1 所示,已知各构件的尺寸L1,L2,L3,L4及原动件 1 的角位移1和等角速度1,求构件 2 和 3 的角位移2,3,角速度2,3,角加速度2,3。8设定机架1长度,L2=101.6设定曲柄2长度,L3=254 设定连杆3长度,L4=177.8解:设L1=304。设定摇杆 4 长度。曲柄摇杆机构运动分析%(1)-为了计算连杆的输出角 th3和摇杆的输出角 th4%设定各杆的长度(单位:毫米)Ntrpss函数funct th3,th4=ntrpss(th,rs)L=sqrt(rs(1)*rs(1)+rs(2)rs(2)2rs(1)rs(2)cos(th(1)+0。4867);phi=asin((rs(2)*sin(th(1))+90)/L);beta=acos((rs(4)*rs(4)+L*L-rs(3)*rs(3)/(2rs(4)*L));if beta 0 beta=beta+pi;endth4=pi-phi beta;th3=asin((rs(4)sin(th4)-rs(2)sin(th(1)90。00)/rs(3));end主函数:clearrs(1)=304。8;rs(2)=101。6;rs(3)=254;rs(4)=177。8;dr=pi/180.0;%设定初始推测的输入 机构的初始位置th(1)=0。0;th(2)=45*dr;th(3)=135 dr;%摇杆 4 的初始位置角可以用三角形的正弦定理确定th(3)=pi-asin(sin(th(2))rs(3)/rs(4))dth=5*dr;for i=1:72th3,th4=ntrps(th,rs);th34(i,:)=th(1)/dr th3/dr th4/dr;%th(1)=th(1)+dth;th(2)=th3;th(3)=th4;endsubplot(2,2,1)plot(th34(:,1),th34(:,2),th34(:,1),th34(:,3);axis(0 360 0 170)gridxlabel(时间/秒)ylabel(从动件角位移/度)title(角位移线图)text(110,110,摇杆 4 角位移)text(50,35,连杆 3 角位移)(2)-计算连杆的角速度 om3 和摇杆的角速度 om4%Setting initial conditionsom2=250;T=2pi/om2;for i=1:72t=iT/72;ct(2)=idth;A=rs(3)sin(th34(i,2)*dr)rs(4)*sin(th34(i,3)*dr);rs(3)*cos(th34(i,2)dr)-rs(4)*cos(th34(i,3)dr);B=om2*rs(2)*sin(ct(2);om2rs(2)*cos(ct(2));om=inv(A)B;om3=om(1);om4=om(2);om34(i,:)=t om3 om4;endsubplot(2,2,2)%plot(om34(:,1),om34(:,2),om34(:,1),om34(:,3))axis(0 0。026 190 210)gridtitle(角速度线图)xlabel(时间/秒)ylabel(从动件角速度)text(0。001,170,摇杆 4 角速度)text(0.013,130,摇杆 3 角速度)%(3)-计算连杆的角加速度 a3 和摇杆的角加速度 a4a2=0;for i=1:72t=i*T/72;c(2)=idth;C=-rs(3)*sin(th34(i,2)dr)rs(4)sin(th34(i,3)*dr);rs(3)cos(th34(i,2)dr)rs(4)cos(th34(i,3)*dr);D(1)=a2*rs(2)*sin(c(2))+om22rs(2)cos(c(2))+om34(i,2)2*rs(3)cos(th34(i,2)*dr)-om34(i,3)2rs(4)*cos(th34(i,3)dr);D(2)=-a2rs)+om342*rs(2)cos(c(2)+om22*rs(2)sin(c(2)(i,2)(3)sin(th34(i,2)*dr)-om34(i,3)2*rs(4)*sin(th34(i,3)dr);a=inv(C)*D;a3=a(1);a4=a(2);a34(i,:)=t a3 a4;endsubplot(2,2,3)plot(a34(:,1),a34(:,2),a34(:,1),a34(:,3)axis(0 0.026 60000 80000)gridtitle(角加速度线图)xlabel(时间)ylabel(从动件加速度)text(0。003,62000,摇杆 4 角加速度)text(0。010,33000,摇杆 3 角加速度)disp 曲柄转角 连杆转角摇杆转角-连杆角速度-摇杆角速度-连杆加速度-摇杆加速度ydcs=th34(:,1),th34(:,2),th34(:,3),om34(:,2),om34(:,3),a34(:,2),a34(:,3);disp(ydcs)3、已知图中机构以下参数:1)、各构件尺寸(5 个长度);LAB=80mm,LBC=260mm,LCD=300mm,LCE=100mm,LEF=460mm。2)、各构件重量及重心位置;G1=36N,S1在 A 点,G2=60N,S2在 BC 中点,G3=72N,S3在 C 点,G4=85N,S4在 EF 中点,G5=85N,S5在 F 点。3)、各构件对重心的转动惯量(4 个转动构件);I1=0.03kgm2,I2=0.08kgm2,I3=0.1 kgm2,I4=0。12 kgm2。4)、阻力:注意推程为正、回程为负;作用在滑块 5 上的水平阻力(生产阻力)Pr=-4000N。当回程时,Pr=50N。5)、曲柄顺时针回转曲柄顺时针回转,n1=400r/min 转动的转速(注意转速单位)用 matlab 求解:1)滑块 5 的位移线图(s)、速度线图(v-)、加速度线图(a)。这里 指曲柄转过的角度,曲柄从右边水平开始,逆时针计算角度逆时针计算角度 0 02 2。2)作原动件 1 的平衡力矩线图。3)编写界面程序,要求当输入曲柄某一角度 值时,可计算出所有运动副反力R12,R23,R34,R56,R61,R63。要求最低实现以下基本功能:其他格式自定.clearrs(1)=0.19235;rs(2)=0.08;rs(3)=0.26;rs(4)=0。30;rs(5)=0。40;rs(6)=0。460;e=0。090;dr=pi/180。0000;th(1)=0。0000;th(2)=50。3800*dr;th(3)=75。3600*dr;dth=dr;for i=1:360th3,th4=ntrpss(th,rs);th5=-asin((rs(5)sin(th4)-e)/rs(6);s=0.170+rs(5)*cos(th4)+rs(6)*cos(th5);th34(i,:)=th(1)/dr th3/dr th4/dr th5/dr s;th(1)=th(1)+dth;th(2)=th3;th(3)=th4;endom2=400;T=2*pi/om2;for i=1:360t=i*T/360;ct(2)=i*dth;A=rs(3)sin(th34(i,2)*dr)rs(4)sin(th34(i,3)*dr);rs(3)*cos(th34(i,2)*dr)rs(4)cos(th34(i,3)dr);B=om2rs(2)*sin(ct(2);-om2rs(2)cos(ct(2));om=inv(A)*B;om3=om(1);om4=om(2);C=rs(6)*sin(th34(i,4)dr)1;rs(6)*cos(th34(i,4)*dr)0;D=-om(2)rs(5)*sin(th34(i,3)dr);om(2)*rs(5)cos(th34(i,3)dr);on=inv(C)D;om5=on(1);om6=on(2);om34(i,:)=t om3 om4 om5 om6;enda2=0;for i=1:360t=iT/360;c(2)=idth;E=-rs(3)*sin(th34(i,2)dr)rs(4)*sin(th34(i,3)*dr);rs(3)cos(th34(i,2)*dr)rs(4)*cos(th34(i,3)dr);F(1)=a2*rs(2)*sin(c(2)+om2*om2rs(2)*cos(c(2)+om34(i,2)om34(i,2)*rs(3)cos(th34(i,2)*dr)om34(i,3)*om34(i,3)rs(4)*cos(th34(i,3)*dr);F(2)=-a2*rs(2)*cos(c(2)+om2*om2*rs(2)*sin(c(2))+om34(i,2)*om34(i,2)*rs(3)*sin(th34(i,2)*dr)-om34(i,3)om34(i,3)rs(4)sin(th34(i,3)*dr);a=inv(E)*F;a3=a(1);a4=a(2);G=rs(6)sin(th34(i,4)*dr)1;-rs(6)*cos(th34(i,4)dr)0;H=om34(i,3).*om34(i,3)*rs(5)*cos(th34(i,3)-om34(i,4)。om34(i,4)rs(6)cos(th34(i,4);om34(i,3)。*om34(i,3)*rs(5)*sin(th34(i,3))om34(i,4).om34(i,4)*rs(6)sin(th34(i,4));b=inv(G)H;b1=b(1);b2=b(2);a34(i,:)=t a3 a4 b1 b2;endsyms p1 p2 p3 p4 jsd1x jsd1y jsd2x jsd2y jsd3x jsd3y jsd4x jsd4y jsd5x jsd5y F2x F2y M2 F3xF3y M3 F5x F5y M5 F6x F1 F2for i=1:360t=iT/360;p1=i*dth;om2=400;a2=0;jsd2x=-0.08om2om2*cos(p1)-0.13(om34(i,2)om34(i,2)*cos(th34(i,2)dr)+a34(i,2)sin(th34(i,2)*dr);jsd2y=-0。08*om2om2*sin(p1)-0.13*(om34(i,2)*om34(i,2)*sin(th34(i,2)*dr)+a34(i,2)*cos(th34(i,2)*dr));jsd3x=-0。3(om34(i,3)*om34(i,3)*cos(th34(i,3)*dr)+a34(i,3)sin(th34(i,3)*dr);jsd3y=-0。3*(om34(i,3)*om34(i,3)sin(th34(i,3)dr)+a34(i,3)*cos(th34(i,3)dr);jsd4x=0.4om34(i,3)*om34(i,3)*cos(th34(i,3)*dr)-0。23(om34(i,4)*om34(i,4)*cos(th34(i,4)*dr)+a34(i,4)sin(th34(i,4)dr));jsd4y=-0.4*om34(i,3)*om34(i,3)sin(th34(i,3)*dr)-0。23(om34(i,4)*om34(i,4)sin(th34(i,4)dr)+a34(i,4)cos(th34(i,4)*dr);jsd5x=-0.4*om34(i,3)om34(i,3)cos(th34(i,3)dr)-0.46(om34(i,4)*om34(i,4)cos(th34(i,4)dr)+a34(i,4)sin(th34(i,4)dr));F2x=-60/9。8jsd2x;F2y=60/9。8jsd2y;M2=0.08*a34(i,2);F3x=-72/9.8*jsd3x;F3y=72/9.8*jsd3y;M3=0.1*a34(i,3);F5x=-85/9.8jsd4x;F5y=-85/9。8jsd4y;M5=0。12a34(i,4);F6x=85/9。8*jsd5x;F1=4000。0;X=0 1 0 1 0 0 0 0 0 0 0 0 0 0 01 0 1 0 0 0 0 0 0 0 0 0 0 0 00 0-0.08*sin(p1)0。08cos(p1)0 0 0 0 0 0 0 0 0 0 10 0 0-1 0 1 0 0 0 0 0 0 0 0 00 0 1 0 1 0 0 0 0 0 0 0 0 0 00 0 0.13sin(th34(i,2)*dr)0.13*cos(th34(i,2)*dr)-0.13*sin(th34(i,2)dr)0。13sin(th34(i,2)*dr)0 0 0 0 0 0 0 0 00 0 0 0 0-1 0 1 0 1 0 0 0 0 00 0 0 0 1 0 1 0 1 0 0 0 0 0 00 0 0 0 0 0 0。3sin(th34(i,3)*dr)-0。3cos(th34(i,3)dr)-0。1sin(th34(i,3)*dr)0。1*cos(th34(i,3)*dr)0 0 0 0 00 0 0 0 0 0 0 0 1 0 1 0 0 0 00 0 0 0 0 0 0 0 0 1 0 1 0 0 00 0 0 0 0 0 0 0-0。23sin(th34(i,4)dr)0。23*cos(th34(i,4)*dr)0。23sin(th34(i,4)*dr)0。23cos(th34(i,4)*dr)0 0 00 0 0 0 0 0 0 0 0 0 0 1 0 1 00 0 0 0 0 0 0 0 0 0 0 0-1 0 0;Z=0 0 0 F2y F2x M2 F3y-F3x M3-F5x F5y M5 0 F6x+F1 0;t=X/Z;t15=t(15)power(i,:)=t t15;endplot(power(:,1),power(:,2))