Subsystem reference won't load properly into Simulink model
33 次查看(过去 30 天)
显示 更早的评论
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 个评论
Mark McBroom
2023-3-25
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.
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Interactive Model Editing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!