Simulink: Model referencing of MATLAB System. Parameters not set in setupImpl
2 views (last 30 days)
Show older comments
Hi everyone,
I have some issues in initialization of a MATLAB System block with interpreted execution. My model hierachy looks like this:
ParentModel
|-ModelRefA
|-ModelRefB
|-MyLibWithMATLABSystem
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:
% ...
properties
MyProp = getDefaultPropValue();
end
% ....
function setupImpl(obj)
test = obj.MyProp; % <-- always shows default parameter but not model argument parameter
% Some other code for initialization, relying on MyProp
end
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!
0 Comments
Answers (1)
Ludo Houben
on 3 Jan 2024
Hi
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:
Regards
Ludo
0 Comments
See Also
Categories
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!