MATLAB: How to access Fundamental Sample Time value within a simulink model

accessing config parametersfundamental sample timesimulink

I have a model will run fixed step discrete. Some of the subsystems I must use require the value of the fundamental step time as an input.
The quick version is, of course, to use a constant as an input and set it equal to the value of the fundamental sample time that's input in the configuration parameters.
And, of course, this method is an invitation to subtle bugs when the configuration parameter is changed but someone forgets to change one of the constant blocks to match.
So – is there a way to simply pull in the value that's been set within the configuration parameters?
Thanks.

Best Answer

SampleTime = get_param(MdlName,'FixedStep')
gives you the Fixed-step size (fundamental sample time) as specified in Simulation > Configuration Parameters.
You could also use this inside a model callback (startfcn) to ensure that value is present in the base when the model is simulated.
Refer Link for more information.