How can I replace my Model Reference block with a Subsystem in Simulink?

62 views (last 30 days)
How do I substitute each of the model reference blocks in a model with subsystems with the same contents as that of the referenced model? Is there a function that can apply this conversion to all nested levels of referenced models?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 18 Oct 2013
Please note that the following technique is not officially supported by MathWorks. There are many features of model reference that do not translate to subsystems. One example of this is the model workspace for the referenced model.
However, if you wish to attempt this, attached are two functions that achieve the conversion. Also attached are some example models to demonstrate the functionality:
1. Replace_MdlRef_SubSys.m -> This is the main function to be called. Provide the name of the top level model that contains the model reference blocks as the only input argument to this function;
2. slcopy_mdl2subsys.m -> This is the function that actually copies the contents of the referenced model to a sub-system.
3. TS_sldemo_absbrake.mdl -> This is a copy of the demo model 'sldemo_absbrake'. The main function will create a new model called 'TS_sldemo_absbrake_new.mdl'
4. TS_sldemo_wheelspeed_absbrake.mdl -> This is the model that is referenced inside TS_sldemo_absbrake.mdl. It is a modified copy of the demo model sldemo_wheelspeed_absbrake. The modification is that this model further references another model called:
5. TS_dummy.mdl
After running the main function on the TS_sldemo_absbrake model, you should have the following new files in your current directory:
1. TS_sldemo_absbrake_new.mdl
2. TS_sldemo_wheelspeed_absbrake_new
You can observe that the TS_sldemo_absbrake_new model has all nested model references replaced by SubSystems.

More Answers (0)

Categories

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

Products


Release

R14SP2

Community Treasure Hunt

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

Start Hunting!