use simulation time in c-code

4 次查看(过去 30 天)
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?

采纳的回答

Ingrid
Ingrid 2012-11-23
ssGetT(S) seems to do the trick

更多回答(0 个)

产品

Community Treasure Hunt

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

Start Hunting!

Translated by