I am trying to set the sample time using the value of an input to the s-function. My code looks as follows:
static void mdlInitializeSampleTimes(SimStruct *S){ ssSetSampleTime(S, 0, 1e-5); ssSetOffsetTime(S, 0, 0.0);}
I would like instead to do the following:
static void mdlInitializeSampleTimes(SimStruct *S) { InputRealPtrsType uPtrs = ssGetInputPortRealSignalPtrs(S,0); ssSetSampleTime(S, 0, *uPtrs[1]); ssSetOffsetTime(S, 0, 0.0); }
However, this does not work at all. I have looked at the simulink examples and the closest thing I found is getting the sample time from the defined parameters in the s-function (which is not exactly what I am looking for). Has anybody tried something similar?
Best Answer