MATLAB: How to pass workspace variables into a reference protected Simulink model in MATLAB R2015b (or R2011b)

argumentbasemodelparametersreferencesimulinkvariableworkspace

I have a model which I want to protect using model protection. Inside the reference model are a few parameters which are taken from the base MATLAB workspace. When I apply model protection (right click -> code generation -> model protection) it seems that the base-workspace variables get hard coded in and I can no longer dynamiclly change these values in between simulations.
How can I have these variables in my protected model reflect changes I make to variables in the base workspace?

Best Answer

The concept of passing arguments to models still apply here desepite being a protected model. You can specify what the input arguments for a reference model to be by following these steps:
Essentially it involves specifying parameter arguments and defining them in the reference model's model-workspace. Afterwards, you will want to apply model protection. Prior to giving this protected model to clients, you will want to inform them of the variables that this reference model will need.
Prior to applying model protection, you can also use this command:
[~, neededVars] = Simulink.ModelReference.protect('gcb')
Where 'gcb' is the model reference block.
neededVars will inform you of any signal objects needed by the reference model - this is a good method for determining what kind of bus signals or simulink parameter objects are needed for the client.