Clear Filters
Clear Filters

Simulink: Model referencing of MATLAB System. Parameters not set in setupImpl

1 view (last 30 days)
Hi everyone,
I have some issues in initialization of a MATLAB System block with interpreted execution. My model hierachy looks like this:
All models are parameterized with model arguments and assigned as arguments to each system propagated from the ParentModel. That works fine and also in my library (MyLibWithMATLABSystem) I get the proper parameters.
My MATLAB System looks like:
% ...
MyProp = getDefaultPropValue();
% ....
function setupImpl(obj)
test = obj.MyProp; % <-- always shows default parameter but not model argument parameter
% Some other code for initialization, relying on MyProp
I assign different values for MyProp as model arguments/mask parameters.
When I test MyLibWithMATLABSystem in a test model everything is working, also when running ModelRefB with loaded parameters in the model workspace. When I use it as a referenced model, I only get the defaults for MyProp.
My guess is, that the initializiation takes place before the model parameters are passed to each submodel.
How to solve that problem or where do I have my logical error?
Thanks for your help!

Answers (1)

Ludo Houben
Ludo Houben on 3 Jan 2024
I have the same 'challenge'. I would like to use a loaded struct for the parameterization of a function, but it is vital that the info is already present when the block is created. I'm still finding the real solution but maybe my workaround also works for you:


Find more on Create Large-Scale Model Components in Help Center and File Exchange




Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!