Matlab课程设计
李俊机自091
设计题目一:凸轮机构设计
已知轮廓为圆形的凸轮(圆的半径为100mm、偏心距为20mm),推杆与凸
轮运动中心的距离20mm,滚子半径为10mm,请利用matlab仿真出凸轮推杆的运动轨迹和运动特性(速度,加速度),并利用动画演示出相关轨迹和运动特性。
%总程序代码
clc;
elf;
clear;
p=figure('positio n' ,[100 100 1200 600]);
for i=1:360
%画圆形凸轮
R=100; %圆形凸轮半径
A=0:0.006:2*pi;
B=i*pi/180;
e=20; %偏心距
a=e*cos(B);
b=e*si n(B); x=R*cos(A)+a;
y=R*s in( A)+b; subplot(1,2,1) plot(x,y,'b','Li neWidth',3);
%填充
fill(x,y,'y') axis([-R-e,R+e,-R-e,R+e+100]);
set(gca,'Xlim',[-R-e,R+e]) set(gca,'Ylim',[-R-e,R+e+100]) axis equal;
axis manu al;
axis off; hold on; plot(a,b,'og') plot(e,0,'or') plot(0,0,'or','Li neWidth',3)
%画滚子
gcx=0; %滚子中心X坐标
r=10; %滚子半径
gcy=sqrt((R+r)A2-a A2)+b; %滚子中心Y 坐标
gx=r*cos(A)+gcx; %滚子X 坐标
gy=r*sin(A)+gcy; %滚子Y 坐标
plot(gx,gy,'b','L in eWidth',2);
%画其它部分
plot([0 a],[0 b],'k','L in eWidth',4)
plot([3 3],[170 190],'m','Li neWidth',4)
plot([-3 -3],[170 190],'m','Li neWidth',4)
%画顶杆
gc=120;
dgx=[0 0];
dgy=[gcy gcy+gc];
plot(dgx,dgy,'L in eWidth',4);
hold off
%画位移图
sx(i)=B;
sy(i)=gcy;
subplot(3,2,2)
plot(sx,sy,'b','Li neWidth',3)
title('位移线图')
grid on
hold off;
%画速度图
vx(i)=B;
vy(i)=20*cos(B) + (40*cos(B).*si n(B)”(121 - 4*COS(B).A2).A(1/2);
subplot(3,2,4)
plot(vx,vy,'g','L in eWidth',3)
title('速度线图')
grid on
hold off;
%画加速度图
ax(i)=B;
ay(i)=(40*cos(B).A2)./(121 - 4*cos(B).A2).A(1/2) - 20*sin(B) - (40*sin(B).A2)/(121 - 4*cos(B).A2).A(1/2) - (160*cos(B)A2.*si n( B).A2)/(121 - 4*cos(B).A2).A(3/2); subplot(3,2,6)
plot(ax,ay,'r','Li neWidth',3),xlabel('B')
title('加速度线图')
grid on
hold off;
M=getframe;
end
截图
E附:通过求导求速度和加速度
%求速度
syms B;
a=e*cos(B);
b=e*si n(B);
s=sqrt((R+r).A2-a.A2)+b;
v=diff(s)
结果:v =20*cos(B) + (40*cos(B)*sin(B)”(121 - 4*cos(BF2)A(1/2)
%求加速度
syms B;
v =20*cos(B) + (40*cos(B)*si n( B))/(121 - 4*cos(B)A2)A(1/2);
a=diff(v)
结果:a =(40*cos(B)A2”(121 - 4*cos(BF2)A(1/2) - 20*sin(B) - (40*sin(B)A2)/(121 - 4*cos(B)A2)A(1/2) - (160*cos(B)A2*si n( BF2”(121 - 4*cos(BF2)A(3/2)