⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 siliangan.m

📁 利用matalb进行机械原理的仿真实验
💻 M
字号:
%%%矩阵法对铰链四杆机构进行运动学分析
%%%2006年4月4日

clear 
global l1 l2 l3 l4 th1 w1

l1=60;
l2=120;
l3=90;
l4=120;
w1=10;

i=0;
th=[0,0];
w=[0,0];
a=[0,0];

th0=[0,0];
for th1=0:0.05:7   
    %%求该时刻点的角位移
    th23=fsolve('Position',th0);
    th2=th23(1);th3=th23(2);
    
    %%求该时刻点的角速度
    A=[-l2*sin(th2) l3*sin(th3)
        l2*cos(th2) -l2*cos(th3)];
    B=[l1*sin(th1);-l1*cos(th1)];    
    w23=inv(A)*(w1*B);
    w2=w23(1);w3=w23(1);
    
    %%求该时刻点的角加速度
    Adot=[-w2*l2*cos(th2) w3*l3*cos(th3)
        -w2*l2*sin(th2) w3*l3*sin(th3)];
    Bdot=[w1*l1*cos(th1);w1*l1*sin(th1)];
    a23=inv(A)*(-Adot*w23+w1*Bdot);
    a2=a23(1);a3=a23(2);
    
    %%将结构存放到一个数组中
    i=i+1;
    th(i,:)=th23;
    w(i,:)=w23';
    a(i,:)=a23';
    
    %%
    th0=th23;
end

th1=0:0.05:7;
plot(th1,th(:,1),'.-',th1,th(:,2),'^-')
figure(2)
plot(th1,w(:,1),'.-',th1,w(:,2),'^-')
figure(3)
plot(th1,a(:,1),'.-',th1,a(:,2),'^-')




%%以下开始制作动画演示
figure(4);
xb=l1*cos(th1);
yb=l1*sin(th1);
xc=l3*cos(th(:,2))+l4;
yc=l3*sin(th(:,2));

axis equal
xmin=min(min(xb),min(xc));
xmax=max(max(xb),max(xc));
ymin=min(min(yb),min(yc));
ymax=max(max(yb),max(yc));
axis([xmin,xmax,ymin,ymax])
%%画初始位置
gan1=line([0,xb(1)],[0,yb(1)],'linewidth',3,'color','b','erasemode','xor');
gan2=line([xb(1),xc(1)],[yb(1),yc(1)],'linewidth',3,'color','r','erasemode','xor');
gan3=line([xc(1),l4],[yc(1),0],'linewidth',3,'color','g','erasemode','xor');
gan4=line([0,l4],[0,0],'linewidth',5,'color','k','erasemode','xor');
%%开始动画
for i=1:length(th1)
    pause(0.2);
    set(gan1,'XData',[0,xb(i)],'YData',[0,yb(i)]);
    set(gan2,'XData',[xb(i),xc(i)],'YData',[yb(i),yc(i)]);
    set(gan3,'XData',[xc(i),l4],'YData',[yc(i),0]);
    drawnow;
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -