Is it possible to pass the sampleTime value as a parameter or an input into a S-function and to use this this value further in the S-function Outputs algorithm?
At the moment I programmed it in the following way: block.SampleTimes = [1e-3 0],
but I would like to have it like this: block.SampleTimes = [s_func_sample_time 0],
in order to specify the sample time somehow from outside of the S-function and to pass this value e.g. via the s_func_sample_time variable. Does there exist a possibility to do this either via the S-function parameter mask (block.NumDialogPrms) or via the S-function inputs (block.InputPort) or in any other way?
My aim is to use this parameter (s_func_sample_time value) further in the S-function Outputs function. E.g. in order to realize a discrete PI-controller. For the I-part it is necessary to know the sample time in order to integrate over the corret time interval. This sample time would be stored in the s_func_sample_time variable and I could use it in the Outputs algorithm.
Best Answer