use simulation time in c-code

2 views (last 30 days)
Ingrid
Ingrid on 23 Nov 2012
I am trying to write an s-function in C-code (to have a better simulation performance). In my simulink model I created first I inserted a clock because my function depends on the current simulation time. With which command can I get the current simulation time in my C-code without having to use an extra inport for the clock in my s-function block?
I am looking for a code like *mxGetPr(mexGetVariable("base", array_name)) which reads in the variable I have in my workspace, but than in this case I would like to read in the simulation time or simulation time step (simulation time not starting from zero so these are not the same and the latter would be the easiest for future use in my code)
I have tried using ssGetSampleTime(S, 0) and ssGetInputPortOffsetTime(S, 0) but both did not work (return 0 when I write it to output). Any thoughts on why not?

Accepted Answer

Ingrid
Ingrid on 23 Nov 2012
ssGetT(S) seems to do the trick

More Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!