平面四连杆机构角度一与角度三之间关系

平面四连杆机构 20190409

供实验数据

实验数据 3232 平面四杆机构

实验数据 1 8 1 8 平面四杆机构 成功
实验数据 1 8 2 7 平面四杆机构 1+8-2-7 成功
实验数据 1 7 8 2 平面四杆机构 1-7+8-2 成功

实验数据 1 7 2 8 平面四杆机构 1-7-2+8 成功


实验数据 2 7 8 1 平面四杆机构 

主函数

function [The1,The3]= f(L,mode)
    clc
    clear
    close all    
%     L=[ 2 7 8 1]
L=[ 2 7 6 10]
    mode=1;
    syms L1 L2 L3 L4 ;
    syms the1 the3 ;
    syms The1 The3 ;
    A=2*L1*L3*sin(the1);
    B=2*L3*(L1*cos(the1)-L4);
    C=L2^2-L1^2-L3^2-L4^2+2*L1*L4*cos(the1);
    D=(A.*A+B.*B-C.*C).^0.5;
    mood1=(A+D)./(B-C);
    mood2=(A-D)./(B-C);
    the3_1=atan(mood1)*2;
    the3_2=atan(mood2)*2;
    L1=L(1) ;
    L2=L(2) ;
    L3=L(3) ;
    L4=L(4) ;
    L=[L1 L2 L3 L4];
    y=ff(L);
    y=y*mode
    X=[0 cos(the1)*L1  L4+cos(the3)*L3 L4];
    Y=[0 sin(the1)*L1  sin(the3)*L3   0];
    for i=1:4
        j=0:0.05:pi;
        the1=j+(i-1)*pi;
        if y(i)==0
            the1=0;
            the3=0;        
        else
            if y(i)>0
                the3=eval(the3_1);
            else
                the3=eval(the3_2);
            end              
        end
        if i==1
            The1=the1;
            The3=the3;            
        else
             The1=[The1,the1];
             The3=[The3,the3];         
        end        
    end
    figure
    plot(The1,The3)
    figure
    hold on;
    t=[-20,20,-20,20]/2;
    axis(t)
    t=1:0.01:4*pi;
    x=[0];
    y=[0];
    plot(cos(t)*L1,sin(t)*L1,'r');
    plot(cos(t)*L3+L4,sin(t)*L3,'b');
    h=plot(x,y,'-o');
    a=length(The1);
    for i=1:a
        the1=The1(i);
        the3=The3(i);        
        set(h,'XData',eval(X),'YData',eval(Y))
        drawnow        
    end
end

功能函数(判断连杆机构类型)

  1. 有一个致命漏洞就是 没有判断连杆类型
  2. 并没有这个漏洞,是自己脑子有坑
function y= ff(L)
% clc
% clear
% close all
% L=[ 2 7 8 1]
    x=sort(L);
    if x(1)+x(4)<=x(2)+x(3)
        if x(1)+x(4)==x(2)+x(3)
            if L(1)+L(2)==L(3)+L(4)
                y= [1 1 -1 -1];
            end
            if  L(1)+L(4)==L(3)+L(2)
                y= [1 -1 -1 1];
            end
            if L(1)+L(2)==L(3)+L(4) && L(1)+L(4)==L(3)+L(2)
                y= [1 -1 1 -1];
            end
            if  L(1)+L(3)==L(2)+L(4)
                y= [1 1 -1 -1];
            end
        else
            y= [1 1 1 1];
        end
    else
        y= [0 0 0 0];
    end
end

保存gif动图

function [The1,The3]= f(L,mode)
    clc
    clear
    close all    
pic_num=1;%     L=[ 2 7 8 1]


L=[ 2 7 6 10]
    mode=1;
    syms L1 L2 L3 L4 ;
    syms the1 the3 ;
    syms The1 The3 ;
    A=2*L1*L3*sin(the1);
    B=2*L3*(L1*cos(the1)-L4);
    C=L2^2-L1^2-L3^2-L4^2+2*L1*L4*cos(the1);
    D=(A.*A+B.*B-C.*C).^0.5;
    mood1=(A+D)./(B-C);
    mood2=(A-D)./(B-C);
    the3_1=atan(mood1)*2;
    the3_2=atan(mood2)*2;
    L1=L(1) ;
    L2=L(2) ;
    L3=L(3) ;
    L4=L(4) ;
    L=[L1 L2 L3 L4];
    y=ff(L);
    y=y*mode
    X=[0 cos(the1)*L1  L4+cos(the3)*L3 L4];
    Y=[0 sin(the1)*L1  sin(the3)*L3   0];
    for i=1:4
        j=0:0.05:pi;
        the1=j+(i-1)*pi;
        if y(i)==0
            the1=0;
            the3=0;        
        else
            if y(i)>0
                the3=eval(the3_1);
            else
                the3=eval(the3_2);
            end              
        end
        if i==1
            The1=the1;
            The3=the3;            
        else
             The1=[The1,the1];
             The3=[The3,the3];         
        end        
    end
    figure
    plot(The1,The3)
    figure
    hold on;
    t=[-20,20,-20,20]/2;
    axis(t)
    t=1:0.01:4*pi;
    x=[0];
    y=[0];
    plot(cos(t)*L1,sin(t)*L1,'r');
    plot(cos(t)*L3+L4,sin(t)*L3,'b');
    h=plot(x,y,'-o');
    a=length(The1);
    for i=1:a
        the1=The1(i);
        the3=The3(i);        
        set(h,'XData',eval(X),'YData',eval(Y))
        drawnow    
        
        
         FF=getframe(gcf)
    F=getframe(gcf);
    I=frame2im(F);
    [I,map]=rgb2ind(I,256);
    
    if pic_num == 1
        imwrite(I,map,'test.gif','gif', 'Loopcount',inf,'DelayTime',0.2);
    else
        imwrite(I,map,'test.gif','gif','WriteMode','append','DelayTime',0.2);
    end
    pic_num = pic_num + 1;
    end
end

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值