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/pi] X1=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);
1
x=[X1 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 on
lineH=plot(x,y, 'b-', 'EraseMode','xor', 'linewidth',2);axis image
rondH=plot(x,y, 'ko', 'EraseMode','xor');axis image
sqH=plot(xs,ys,'msquare','EraseMode','xor', 'linewidth',3);axis image
dotH=plot(X2,Y2, 'r.', 'EraseMode','none');axis image dotD=plot(X5,Y5, 'c.', 'EraseMode','none');axis image axis([-12 12 -12 12]); grid on
N=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);
2
X3=2*X2; Y4=2*Y2; % phi=-phi0+ alfa
X5=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; 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); drawnow end
plot(x2,y2, 'r-', 'linewidth',3);axis image plot(x5,y5, 'c-', 'linewidth',3);axis image axis([-12 12 -12 12]);
3
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/pi] phi=-phi0+ alfa ; X5=X2+l* cos(phi); 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 on
lineH=plot(x,y, 'b-', 'EraseMode','xor', 'linewidth',2);axis image
rondH=plot(x,y, 'ko', 'EraseMode','xor');axis image
sqH=plot(xs,ys,'msquare','EraseMode','xor', 'linewidth',3);axis image
dotH=plot(X2,Y2, 'r.', 'EraseMode','none');axis image dotD=plot(X5,Y5, 'c.', 'EraseMode','none');axis image axis([-12 12 -12 12]); grid on
% N=10000;
4
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+ alfa
X5=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; 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); drawnow end
plot(x2,y2, 'r-', 'linewidth',3);axis image plot(x5,y5, 'c-', 'linewidth',3);axis image
5
axis([-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/pi] phi=-phi0+ alfa ; X5=X2+l* cos(phi); 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,3); hold on
lineH=plot(x,y, 'b-', 'EraseMode','xor', 'linewidth',2);axis image
rondH=plot(x,y, 'ko', 'EraseMode','xor');axis image
sqH=plot(xs,ys,'msquare','EraseMode','xor', 'linewidth',3);axis image
dotH=plot(X2,Y2, 'r.', 'EraseMode','none');axis image dotD=plot(X5,Y5, 'c.', 'EraseMode','none');axis image axis([-12 12 -12 12]); grid on
% N=10000;
6
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+ alfa
X5=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; 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); drawnow end
plot(x2,y2, 'r-', 'linewidth',3);axis image plot(x5,y5, 'c-', 'linewidth',3);axis image
7
axis([-12 12 -12 12]); 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/pi] phi=-phi0+ alfa ; X5=X2+l* cos(phi); 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,4); hold on
lineH=plot(x,y, 'b-', 'EraseMode','xor', 'linewidth',2);axis image
rondH=plot(x,y, 'ko', 'EraseMode','xor');axis image
sqH=plot(xs,ys,'msquare','EraseMode','xor', 'linewidth',3);axis image
dotH=plot(X2,Y2, 'r.', 'EraseMode','none');axis image dotD=plot(X5,Y5, 'c.', 'EraseMode','none');axis image axis([-12 12 -12 12]); grid on
8
% 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+ alfa
X5=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]; 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); drawnow end
9
双滑块机构动态演示
圆半径r=5 点心距l=3 曲柄初相角φ0=30° α=30°~120° MATLAB 6.5
MATLAB7
10
因篇幅问题不能全部显示,请点此查看更多更全内容