MATLAB: How to obtain the compiled value of a block parameter in Simulink 7.9 (R2012a)

simulink

I need to find out the compiled value of a block parameter.
For example, I need to obtain the compiled value of a block´s gain parameter (see attached model test_model).
Using the “get_param(blockname,'gain')” command, I can obtain the string which is contained in the block's dialog box (ex: 'a+b'), but not the compiled value of the parameter.
I do not know in which workspace the variables are defined and therefore in which workspace I can evaluate the expression.
For example the variables a and b could be defined in MATLAB's base workspace or in a mask.

Best Answer

You can obtain the compiled data of a block, using the block's "run time object".
This is documented in the section “Accessing Block Data During Simulation” of Simulink's documentation.
This is an example of a script that returns the compiled value of the gain:
test_model([],[],[],'compile')
rto = get_param('test_model/Subsystem/Gain','RuntimeObject');
compiledData = rto.DialogPrm(1).Data;
disp(compiledData);
test_model([],[],[],'term')