MATLAB: How to use Mask parameters in InitFcn

mask parametersimulink

I am using 2017a. I have a need to use a parameter from the mask of a block in the block property's InitFcn function. Is it possible? I have attached the model so you may see what I mean. Thank you.

Best Answer

You Can access the block parameters of masked subsystem using get_param and change the block parameter using set_param.
You can make these changes inside InitFcn function.
% To get the Block Parameter
Param= get_param([gcs,'/Subsystem'],'Tend');
% To set Block parameter
set_param([gcs,'/Subsystem'],'Tend','6');
I have attached the modified Simulink Model.