Simulink 5: Fundamentos

by

 

15 Jan 2003 (Updated )

Companion Software for "Simulink 5: Fundamentos".

[sys,x0]=animacao (t,x,u,flag);
function [sys,x0]=animacao (t,x,u,flag);
% animacao S-function : cria animacao do salto 'bungie jump'

global BungieAnime % Handle da janela de animacao

if flag==2   % Estado atual: desenha posicao corrente
  if any(get(0,'Children')==BungieAnime),
    if strcmp(get(BungieAnime,'Name'),'Exercicio07 Animation'),
      set(0,'currentfigure',BungieAnime);
      hndlList=get(gca,'UserData');
      x=[0 0];
      y=[0 u(1)];
      set(hndlList(1),'XData',x,'YData',y);       % Desenha corda
      set(hndlList(2),'XData',x(2),'YData',y(2)); % Desenha corpo
      drawnow;
    end
  end
  sys=[];

elseif flag == 4 % 
  
  sys = t+1;
  
elseif flag==0 % Estado Inicial

  animinit('Exercicio07 Animation'); % Inicia tela de animacao
  [flag,BungieAnime] = figflag('Exercicio07 Animation');
  axis([-50 50 -120 10]); % Define Eixos
  hold on;
  x=[0 0];
  y=[0 0];
  plot([-40 40],[0 0],'LineWidth',5)   % Desenha linha base
  hndlList(1)=plot(x,y,'LineWidth',5,'EraseMode','background'); % Desenha corda
  hndlList(2)=plot(0,0,'.','MarkerSize',40,'EraseMode','back'); % Desenha corpo
  set(gca,'DataAspectRatio',[1 1 1]);
  set(gca,'UserData',hndlList);

  sys=[0 0 0 2 0 0];
  x0=[];

end

Contact us