MATLAB: Is it not possible to pass parameters from top-level subsystem’s mask to the Model reference block within the subsystem

simulink

I have a large model which I need to divide into subsystems that will be developed by different team members.
The top level (level 1) of my model consists of one subsystem which has several other subsystems within it. On the second level, I need to convert my subsystems into Model Reference blocks for re-usability.
The problem is that within the level 2 Model Reference block, I use certain variables (parameters) which the user enters in the Mask of the level 1 subsystem. When I enter all the parameters (variables "a" and "b" in this case) in the mask of the level 1 subsystem and try to execute my model, I get the following error:
 
Error using ==> tlc_c at 133
–> Error evaluating parameter 'Gain' in 'on_lvl_2/Gain': Error using ==> rtwgen
Undefined function or variable 'a'.
–> Error evaluating parameter 'Gain' in 'on_lvl_2/Gain1': Error using ==> rtwgen
Undefined function or variable 'b'.

Best Answer

This is intended behavior of the Model Reference block in Simulink 7.1 (R2008a).
To work around this problem, you can parameterize the Model Reference block using the methods described "Parameterizing Model References" documentation page:
Also refer the demo - "sldemo_mdlref_paramargs.mdl" for more information on the parameterizing a Model Reference block.
Another workaround is to define the variables (from the mask of the top-level block) either in the base workspace or the model workspace. You can use EVALIN in the callback of the tunable parameter to achieve this.
Another workaround could be to create library blocks instead of using Model Referencing.