MATLAB: How to obtain the inherited sampling rate of a discrete Simulink block from the MATLAB Command line

compiledsampletimeget_paraminheritedsimulink

How do I obtain the inherited sampling rate of a discrete Simulink block from the MATLAB Command line?
I would like to use the sampling rate of a discrete Simulink block in calculations within a masked subsystem. The sampling rate of this block is -1 (i.e. inherited sample rate). How can I obtain the actual inherited sample rate of this block from the Command line (e.g 0.0025 instead of -1)?

Best Answer

You can determine the compiled sample time of any block in a model by first updating the model and then accessing the block's CompiledSampleTime parameter, using the GET_PARAM command. For example
get_param(gcb,'compiledsampletime') %where gcb is the block most recently clicked on
For more information regarding this parameter, please see the "Specifying Sample Time" section of the Simulink documentation
If you have the documentation installed, you may also view the same information using MATLAB's help browser by executing the following command at the MATLAB prompt:
web([docroot,'/toolbox/simulink/ug/f7-9753.html'])