MATLAB SIMULINK 7 - DEVELOPING S-FUNCTIONS Podręcznik Użytkownika Strona 41

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 210
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 40
Examples of M-File S-Functions
2-17
% End of mdlUpdate.
%
%==============================================================
% mdlOutputs
% Return the output vector for the S-function.
%==============================================================
%
function sys = mdlOutputs(t,x,u,doffset,dperiod)
% Return output of the unit delay if we have a
% sample hit within a tolerance of 1e-8. If we
% don't have a sample hit then return [] indicating
% that the output shouldn't change.
%
if abs(round((t-doffset)/dperiod)-(t-doffset)/dperiod) < 1e-8
sys = x(2);
else
sys = []; % This is not a sample hit, so return an empty
end % matrix to indicate that the output has not changed
% End of mdlOutputs.
Example - Variable Step S-Functions
This M-file is an example of an S-function that uses a variable step time. This
example, in an M-file called
vsfunc.m, calls mdlGetTimeOfNextVarHit when
flag = 4. Because the calcula tion of a next sample time depends on the input
u, this block has direct feedthrough. Generally, all blocks that use the input to
calculate the next sample time (
flag = 4) require direct feedthrough. Here is
the code for the M-file S-function:
Przeglądanie stron 40
1 2 ... 36 37 38 39 40 41 42 43 44 45 46 ... 209 210

Komentarze do niniejszej Instrukcji

Brak uwag