1、双滑块机构MATLAB演示% 双滑块机构MATLAB演示close all h = figure; set(gcf,outerposition,get(0,screensize); % 窗口最大化操作r= 5 ; l= 3 ; phi0= 30 *pi/180; alfa= 30 *pi/180;r l phi0*180/pi alfa*180/piX1=0;Y1=0;X2=r*cos(phi0);Y2=r*sin(phi0);X3=2*X2;Y3=0;X4=0;Y4=2*Y2;phi=-phi0+ alfa ;X5=X2+l* cos(phi);Y5=Y2+l* sin (phi);x=X1
2、 X2 X3 X4 X2 X5;y=1:6;y=Y1 Y2 Y3 Y4 Y2 Y5;xs=X3 X4;ys=1:2;ys=Y3 Y4;subplot(2,2,1);hold onlineH=plot(x,y, b-, EraseMode,xor, linewidth,2);axis imagerondH=plot(x,y, ko, EraseMode,xor);axis imagesqH=plot(xs,ys,msquare,EraseMode,xor, linewidth,3);axis imagedotH=plot(X2,Y2, r., EraseMode,none);axis image
3、dotD=plot(X5,Y5, c., EraseMode,none);axis imageaxis(-12 12 -12 12);grid onN=10000;X2=1:N+1; y2=1:N+1;x5=1:N+1; y5=1:N+1;for i=0:N X2=r*cos(phi0+2*pi*i/N);Y2=r*sin(phi0+2*pi*i/N);X3=2*X2;Y4=2*Y2;% phi=-phi0+ alfaX5=X2+l* cos(phi-2*pi*i/N);Y5=Y2+l* sin (phi-2*pi*i/N);xd=X1 X2 X3 X4 X2 X5;yd=1:6; yd=Y1
4、 Y2 Y3 Y4 Y2 Y5;xsd=X3 X4;ysd=1:2;ysd=Y3 Y4;x2(i+1)=X2; y2(i+1)=Y2;x5(i+1)=X5; y5(i+1)=Y5; set(lineH, xdata,xd, ydata,yd); set(rondH, xdata,xd, ydata,yd); set(sqH, xdata,xsd, ydata,ysd); set(dotH, xdata,X2, ydata,Y2);set(dotD, xdata,X5, ydata,Y5); drawnowendplot(x2,y2, r-, linewidth,3);axis imageplo
5、t(x5,y5, c-, linewidth,3);axis imageaxis(-12 12 -12 12);grid on% 此外,MATLAB也可对图形加上各种注解与处理:text(-10,-10,王允地编双滑块机构分析程序); % x,y处插入文字 xlabel(横轴x); % x轴注解 ylabel(纵轴y); % y轴注解 title(双滑块机构动态演示); % 图形标题 legend(杆件,铰链, 滑块, 动铰轨迹, 杆点轨迹); alfa= 60 *pi/180;r l phi0*180/pi alfa*180/piphi=-phi0+ alfa ;X5=X2+l* cos(p
6、hi);Y5=Y2+l* sin (phi);x=X1 X2 X3 X4 X2 X5;y=1:6; y=Y1 Y2 Y3 Y4 Y2 Y5;subplot(2,2,2);hold onlineH=plot(x,y, b-, EraseMode,xor, linewidth,2);axis imagerondH=plot(x,y, ko, EraseMode,xor);axis imagesqH=plot(xs,ys,msquare,EraseMode,xor, linewidth,3);axis imagedotH=plot(X2,Y2, r., EraseMode,none);axis im
7、agedotD=plot(X5,Y5, c., EraseMode,none);axis imageaxis(-12 12 -12 12);grid on % N=10000;for i=0:N X2=r*cos(phi0+2*pi*i/N);Y2=r*sin(phi0+2*pi*i/N);X3=2*X2; Y4=2*Y2;% phi=-phi0+ alfaX5=X2+l* cos(phi-2*pi*i/N);Y5=Y2+l* sin (phi-2*pi*i/N);xd=X1 X2 X3 X4 X2 X5;yd=1:6; yd=Y1 Y2 Y3 Y4 Y2 Y5;xsd=X3 X4;ysd=1
8、:2; ysd=Y3 Y4;x2(i+1)=X2; y2(i+1)=Y2;x5(i+1)=X5; y5(i+1)=Y5; set(lineH, xdata,xd, ydata,yd); set(rondH, xdata,xd, ydata,yd); set(sqH, xdata,xsd, ydata,ysd); set(dotH, xdata,X2, ydata,Y2);set(dotD, xdata,X5, ydata,Y5); drawnowendplot(x2,y2, r-, linewidth,3);axis imageplot(x5,y5, c-, linewidth,3);axis
9、 imageaxis(-12 12 -12 12);grid on% 此外,MATLAB也可对图形加上各种注解与处理:% text(-10,-10,王允地编双滑块机构分析程序); % x,y处插入文字 xlabel(横轴x); % x轴注解 ylabel(纵轴y); % y轴注解 title(双滑块机构动态演示); % 图形标题 % legend(杆件,铰链, 滑块, 动铰轨迹, 杆点轨迹); alfa= 90 *pi/180;r l phi0*180/pi alfa*180/piphi=-phi0+ alfa ;X5=X2+l* cos(phi);Y5=Y2+l* sin (phi);x=X
10、1 X2 X3 X4 X2 X5;y=1:6; y=Y1 Y2 Y3 Y4 Y2 Y5;subplot(2,2,3);hold onlineH=plot(x,y, b-, EraseMode,xor, linewidth,2);axis imagerondH=plot(x,y, ko, EraseMode,xor);axis imagesqH=plot(xs,ys,msquare,EraseMode,xor, linewidth,3);axis imagedotH=plot(X2,Y2, r., EraseMode,none);axis imagedotD=plot(X5,Y5, c., Er
11、aseMode,none);axis imageaxis(-12 12 -12 12);grid on % N=10000;for i=0:N X2=r*cos(phi0+2*pi*i/N);Y2=r*sin(phi0+2*pi*i/N);X3=2*X2; Y4=2*Y2;% phi=-phi0+ alfaX5=X2+l* cos(phi-2*pi*i/N);Y5=Y2+l* sin (phi-2*pi*i/N);xd=X1 X2 X3 X4 X2 X5;yd=1:6; yd=Y1 Y2 Y3 Y4 Y2 Y5;xsd=X3 X4;ysd=1:2; ysd=Y3 Y4;x2(i+1)=X2;
12、y2(i+1)=Y2;x5(i+1)=X5; y5(i+1)=Y5; set(lineH, xdata,xd, ydata,yd); set(rondH, xdata,xd, ydata,yd); set(sqH, xdata,xsd, ydata,ysd); set(dotH, xdata,X2, ydata,Y2);set(dotD, xdata,X5, ydata,Y5); drawnowendplot(x2,y2, r-, linewidth,3);axis imageplot(x5,y5, c-, linewidth,3);axis imageaxis(-12 12 -12 12);
13、grid on% 此外,MATLAB也可对图形加上各种注解与处理:% text(-10,-10,王允地编双滑块机构分析程序); % x,y处插入文字 xlabel(横轴x); % x轴注解 ylabel(纵轴y); % y轴注解 title(双滑块机构动态演示); % 图形标题 % legend(杆件,铰链, 滑块, 动铰轨迹, 杆点轨迹); alfa= 120 *pi/180;r l phi0*180/pi alfa*180/piphi=-phi0+ alfa ;X5=X2+l* cos(phi);Y5=Y2+l* sin (phi);x=X1 X2 X3 X4 X2 X5;y=1:6; y
14、=Y1 Y2 Y3 Y4 Y2 Y5;subplot(2,2,4);hold onlineH=plot(x,y, b-, EraseMode,xor, linewidth,2);axis imagerondH=plot(x,y, ko, EraseMode,xor);axis imagesqH=plot(xs,ys,msquare,EraseMode,xor, linewidth,3);axis imagedotH=plot(X2,Y2, r., EraseMode,none);axis imagedotD=plot(X5,Y5, c., EraseMode,none);axis imagea
15、xis(-12 12 -12 12);grid on % N=10000;% 此外,MATLAB也可对图形加上各种注解与处理:% text(-10,-10,王允地编双滑块机构分析程序); % x,y处插入文字 xlabel(横轴x); % x轴注解 ylabel(纵轴y); % y轴注解 title(双滑块机构动态演示); % 图形标题 % legend(杆件,铰链, 滑块, 动铰轨迹, 杆点轨迹); for i=0:N X2=r*cos(phi0+2*pi*i/N);Y2=r*sin(phi0+2*pi*i/N);X3=2*X2; Y4=2*Y2;% phi=-phi0+ alfaX5=X2
16、+l* cos(phi-2*pi*i/N);Y5=Y2+l* sin (phi-2*pi*i/N);xd=X1 X2 X3 X4 X2 X5;yd=1:6; yd=Y1 Y2 Y3 Y4 Y2 Y5;xsd=X3 X4;ysd=1:2; ysd=Y3 Y4; set(lineH, xdata,xd, ydata,yd); set(rondH, xdata,xd, ydata,yd); set(sqH, xdata,xsd, ydata,ysd); set(dotH, xdata,X2, ydata,Y2);set(dotD, xdata,X5, ydata,Y5); drawnowend双滑块机构动态演示 圆半径r=5 点心距l=3 曲柄初相角0=30 =30120 MATLAB 6.5 MATLAB7
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1