Referenced models let you use one Simulink model inside another. This helps you build big systems by combining smaller parts.
Referenced models in Simulink
1. Open your main Simulink model. 2. Drag a 'Model' block from the Simulink Library Browser. 3. Double-click the 'Model' block. 4. Enter the name of the referenced model file (without .slx). 5. Save and run the main model.
The referenced model file must be saved and accessible in the MATLAB path.
Changes in the referenced model automatically update in the main model.
Model block parameter: 'Referenced model name' = 'motor_control'
Use multiple Model blocks to include 'sensor', 'controller', and 'actuator' models.
This code creates a simple referenced model with a Gain block multiplying input by 5. The main model sends a constant value 2 to the referenced model and outputs the result. The output should be 10.
% Create a simple referenced model example % Step 1: Create a referenced model 'simple_gain.slx' with a Gain block % Step 2: Create a main model 'main_model.slx' and add a Model block referencing 'simple_gain' % For demonstration, simulate the referenced model programmatically % Create referenced model new_system('simple_gain') add_block('simulink/Commonly Used Blocks/Gain','simple_gain/Gain') set_param('simple_gain/Gain','Gain','5') save_system('simple_gain') close_system('simple_gain') % Create main model new_system('main_model') add_block('simulink/Commonly Used Blocks/Model','main_model/ReferencedModel') set_param('main_model/ReferencedModel','ModelName','simple_gain') add_block('simulink/Commonly Used Blocks/Constant','main_model/Constant') set_param('main_model/Constant','Value','2') add_block('simulink/Commonly Used Blocks/Out1','main_model/Out1') % Connect blocks add_line('main_model','Constant/1','ReferencedModel/1') add_line('main_model','ReferencedModel/1','Out1/1') save_system('main_model') % Simulate main model simOut = sim('main_model'); % Get output output = simOut.get('yout'); % Display output fprintf('Output of referenced model simulation: %g\n', output.signals.values(end));
Referenced models help keep your projects clean and organized.
Make sure referenced models are saved before running the main model.
You can update referenced models independently without changing the main model.
Referenced models let you reuse and organize Simulink models easily.
They help build complex systems from smaller parts.
Changes in referenced models update automatically in the main model.
Practice
Referenced models in Simulink?Solution
Step 1: Understand the role of referenced models
Referenced models allow you to include one model inside another, making reuse possible.Step 2: Connect reuse to project management
By reusing parts, you keep big projects organized and easier to update.Final Answer:
To reuse parts of models and simplify large projects -> Option AQuick Check:
Referenced models = reuse and simplify [OK]
- Confusing referenced models with creating new blocks
- Thinking referenced models speed up simulation by skipping
- Assuming referenced models export images
Solution
Step 1: Recall how to include referenced models
Simulink uses Model blocks to include referenced models by specifying the model file name.Step 2: Check options for correctness
Drag a Model block and set its Model name parameter to the referenced model file correctly describes dragging a Model block and setting its Model name parameter.Final Answer:
Drag a Model block and set its Model name parameter to the referenced model file -> Option AQuick Check:
Model block + Model name = referenced model [OK]
- Using add_block without parameters causes errors
- Copy-pasting duplicates instead of referencing
- Naming subsystems does not create references
subsystemA, what happens if subsystemA is updated externally and saved before simulation?Solution
Step 1: Understand referenced model behavior on update
Referenced models reflect changes made externally when saved before simulation.Step 2: Analyze simulation effect
The main model uses the latest saved version of the referenced model during simulation.Final Answer:
The main model uses the updatedsubsystemAduring simulation -> Option CQuick Check:
Referenced models update = main model uses latest [OK]
- Assuming main model caches old referenced model version
- Thinking simulation fails if referenced model changes
- Believing referenced models duplicate automatically
Model file not found. What is the most likely cause?Solution
Step 1: Identify cause of 'Model file not found'
This error usually means Simulink cannot locate the referenced model file due to wrong or missing path.Step 2: Check other options for relevance
Saving main model, input ports, or simulation time do not cause this error.Final Answer:
The referenced model file path is incorrect or missing -> Option BQuick Check:
File not found = wrong or missing path [OK]
- Ignoring file path issues
- Blaming simulation time or ports incorrectly
- Not saving main model but error is unrelated
Solution
Step 1: Understand team collaboration with referenced models
Referenced models allow teams to work on separate model files independently.Step 2: Connect referenced models to main model integration
The main model includes these referenced models, making integration easier and organized.Final Answer:
Each team works on separate referenced models that are included in the main model, easing collaboration -> Option DQuick Check:
Referenced models = team collaboration and modular design [OK]
- Thinking referenced models merge files automatically
- Assuming referenced models lock changes
- Believing referenced models simulate independently without integration
Ready to prove it?
Pass the test and this pattern moves unknown
