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

📄 sfuntmpl.s

📁 MATLAB简单应用
💻 S
字号:
function [sys,x0] = antsim38(t,x,u,flag,ts)
global xSpr2 xBx12 xBx22 sim38
offset=4;
if flag==2,
    if any(get(0,'Children')==sim38),
        if strcmp(get(sim38,'Name'),'sim38 Animation'),
            set(0,'currentfigure',sim38)
            u(2)=u(2)+offset;
            distance=u(2)-u(1);
            hnd1=get(gca,'UserData');
            x=[xBx12+u(1); xSpr2/4*distance+u(1); xBx22+distance+u(1)];
                set(hnd1,'XData',x);
                drawnow;
            end
        end
        sys=[];
    elseif flag==4
        ns=t/ts;
        sys=(1+floor(ns+1e-13*(1+ns)))*ts;
    elseif flag==0,
        animinit('sim38 Animation');
        sim38=findobj('Type','figure','Name','sim38 Animation');
        axis([-10 20 -7 7]);
        hold on;
        xySpr2=[ ...
                0.0   0.0
                0.4   0.0
                0.8   0.65
                1.6   -0.65
                2.4   0.65
                3.2   -0.65
                3.6   0.0
                4.0   0.0];
         xyBx12=[   ...
                 0.0   1.1
                 0.0   -1.1
                 -2.0   -1.1
                 -2.0   1.1
                 0.0    1.1 ];
          xyBx22=[   ...
                  0.0   1.1
                  2.0   1.1
                  2.0   -1.1
                  0.0   -1.1
                  0.0   1.1];
           
        xBx12=xyBx12(:,1);
        yBx12=xyBx12(:,2);
        xBx22=xyBx22(:,1);
       yBx22=xyBx22(:,2);
       xSpr2=xySpr2(:,1);
        xSpr2=xySpr2(:,2);
        x=[xBx12; xSpr2; xBx22(:,1)+offset];
        y=[yBx12; ySpr2; yBx22];
        plot([-10 20],[-1.3 -1.3], 'yellow',...
            [-10:19;-9:20],[-2 -1.3],'yellow','LineWidth',2);
        hnd1=plot(x,y,'y','EraseMode','background','LineWidth',3);
        set(gca,'UserData',hnd1);
        sys=[0 0 0 2 0 0];
        x0=[];
    end;
        
               

⌨️ 快捷键说明

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