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

  • 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 82
Overview of the C MEX S-Function Routines
3-39
To check for a sample hit during execution (in mdlOutputs or mdlUpdate), use
the
ssIsSampleHit or ssIsContinuousTask macro. For example, if your first
sample time is continuous, then you used the following code fragment to check
for a sample hit. Note that you would get incorrect results if you used
ssIsSampleHit(S,0,tid).
if (ssIsContinuousTask(S,tid)) {
}
If, for example, you wanted to determine if the third (discrete) task has a hit,
then you would use the following code-fragment:
if (ssIsSampleHit(S,2,tid) {
}
The synopsis is:
static void mdlInitializeSampleTimes(SimStruct *S)
{
} /* End of mdlInitializeSampleTimes. */
Example: mdlInitializeSampleTimes.
This example specifies that there are two
discrete sample times with periods of 0.01 and 0.5 seconds.
static void mdlInitializeSampleTimes(SimStruct *S)
{
ssSetSampleTime(S, 0, 0.01);
ssSetOffsetTime(S, 0, 0.0);
ssSetSampleTime(S, 1, 0.5);
ssSetOffsetTime(S, 1, 0.0);
} /* End of mdlInitializeSampleTimes. */
Port-based Sample Times
The next three section discuss how to specify port-based sample times. You
must s pecify information in
mdlInitializeSizes
mdlSetInputPortSampleTime
mdlSetOutputPortSampleTime
Vue de la page 82
1 2 ... 78 79 80 81 82 83 84 85 86 87 88 ... 209 210

Commentaires sur ces manuels

Pas de commentaire