Subsystem reference won't load properly into Simulink model
33 views (last 30 days)
Show older comments
Giovanni Gasperini
on 22 Mar 2023
Answered: Giovanni Gasperini
on 29 Mar 2023
Hello,
I have project with the following structure:
- a folder containing a Simulink file "A",
- a folder containing a subfolder which hosts a masked subsystem file "B".
Simulink file "A" contains a subsytem reference to "B"; "B" has a model mask containing several non-tunable parameters. "A" has an init function which is automatically invoked before the start of every simulation, which is supposed to assign values to the parameters contained within "B" 's mask.
Everything works as it should if I open "B", then "A", then launch a simulation in "A". However if, instead, I select both folders and click "Add to Path -> Selected Folders and Subfolders", then open only "A", the subsystem doesn't seem to load properly. In particular, it seems to load without its mask. A warning also appears in the simulink diagnostics screen saying that the subsystem reference couldn't be updated because there are not enough input arguments, which I have no clue what it could possibly mean in this case.
All sorts of strange errors also tend to appear in the command window, sometimes saying that some Stateflow block couldn't be copied to the clipboard because it was corrupted. I'm not using Stateflow in this project at all, so again, no clue.
I hope this was clear enough, unfortunately I am pretty new to both subsystem references and subsystem masks in general, and I haven't been able to find anyone with a similar issue.
3 Comments
Mark McBroom
on 25 Mar 2023
You could try moving your code from an InitFcn callback to a PreLoadFcn callback. It could be that Simulink is trying to open the SubSystem reference before running the content of the InitFcn.
Other general suggestions on your M code. I would remove the clear all code and I would remove the code for setting path and replace with Simulink Projects for managing maths.
Thanks.
Mark.
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Interactive Model Editing 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!