MATLAB SIMULINK 7 - DEVELOPING S-FUNCTIONS Guide de l'utilisateur Page 42

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 210
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 41
2 Writing S-Functions As M-Files
2-18
function [sys,x0,str,ts] = vsfunc(t,x,u,flag)
% This example S-function illustrates how to create a variable
% step block in Simulink. This block implements a variable step
% delay in which the first input is delayed by an amount of time
% determined by the second input:
%
% dt = u(2)
% y(t+dt) = u(t)
%
switch flag,
case 0
[sys,x0,str,ts] = mdlInitializeSizes; % Initialization
case 2
sys = mdlUpdate(t,x,u); % Update Discrete states
case 3
sys = mdlOutputs(t,x,u); % Calculate outputs
case 4
sys = mdlGetTimeOfNextVarHit(t,x,u); % Get next sample time
case { 1, 9 }
sys = []; % Unused flags
otherwise
error(['Unhandled flag = ',num2str(flag)]); % Error handling
end
% End of vsfunc.
%==============================================================
% mdlInitializeSizes
% Return the sizes, initial conditions, and sample times for the
% S-function.
%==============================================================
%
function [sys,x0,str,ts] = mdlInitializeSizes
%
% Call simsizes for a sizes structure, fill it in and convert it
% to a sizes array.
%
Vue de la page 41
1 2 ... 37 38 39 40 41 42 43 44 45 46 47 ... 209 210

Commentaires sur ces manuels

Pas de commentaire