| Writing S-Functions | ![]() |
Get the current time for the current task
Syntax
Arguments
S
SimStruct representing an S-Function block.
st_index
Index of the sample time corresponding to the task for which the current time is to be returned.
Description
Returns the current time (time_T) of the task corresponding to the sample rate specified by st_index. You can use this macro in mdlOutputs and mdlUpdate to compute the output of your block.
The ssGetTaskTime macro should be called only inside an ssIsSampleHit check. It will not give the correct results if called with the tid passed into mdlOutputs. The following example illustrates a correct usage of this macro:
static void mdlOutputs( SimStruct *S, int_T tid ) { double t; if(ssIsSampleHit(S,0,tid)) { t = ssGetTaskTime(S,0); ssPrintf("Task 0 sample hit in %s time = %g\n", ssGetPath(S),t); } if(ssIsSampleHit(S,1,tid)) { t = ssGetTaskTime(S,1); ssPrintf("Task 1 sample hit in %s time = %g\n", ssGetPath(S),t); } }
Languages
See Also
| ssGetT | ssGetTFinal | ![]() |
© 1994-2005 The MathWorks, Inc.