MATLAB SIMULINK 7 - DEVELOPING S-FUNCTIONS Guía de usuario Pagina 14

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 210
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 13
1 Overview of S-Functions
1-8
calls the appropriate functions for each flag value. For a C MEX S-function,
Simulink calls the S-function routines directly. This table lists the simulation
stages, the corresponding S-function routines, and the associated
flag value
for M-file S-functions.
C MEX S-function routines must have exactly the names shown in Table 1-1.
InM-fileS-functions,youmustprovidecodethat,basedonthe
flag value,calls
the appropriate S-function routine. A template M-file S-function,
sfuntmpl.m,
is located in
matlabroot/toolbox/simulink/blocks.Thistemplateusesa
switch statement to handle the flag values.Allyouhavetodoisplaceyour
code in the correct S-function routine.
InCMEXS-functions,SimulinkdirectlycallsthecorrectS-function routinefor
the current simulation stage. A template S-function writte n in C called
sfuntmpl.c, located under simulink/src, is supplied with Simulink. For a
moreamply commented version of the templat e, see
sfuntmpl.doc in the same
directory.
Note We recommend that you use the M-file or C MEX-file template when
developing S-functions.
Table 1-1: Simulation Stages
Simulation Stage S-Function Routine Flag (M-File
S-Functions)
Initialization mdlInitializeSizes flag = 0
Calculation of next sample
hit (optional)
mdlGetTimeOfNextVarHit flag = 4
Calculation of outputs mdlOutputs flag = 3
Update discrete states mdlUpdate flag = 2
Calculation of derivatives mdlDerivatives flag = 1
Endofsimulationtasks mdlTerminate flag = 9
Vista de pagina 13
1 2 ... 9 10 11 12 13 14 15 16 17 18 19 ... 209 210

Comentarios a estos manuales

Sin comentarios