How to reference a model in matlab?

23 次查看(过去 30 天)
I am trying to reference some models inside my main model using model referencing, but its throwing the error that the model is not found. Even though the model is present. Can someone guide me how to do the referencing correctly in simulink?

采纳的回答

Manan Jain
Manan Jain 2023-7-27
Hi!
Model referencing allows you to modularize your Simulink models by creating reusable components that can be used within other main models. This can make your models more organized, easier to maintain, and promote reusability.
Here are the steps to correctly use model referencing in Simulink:
1. Create the Referenced Model:
  • First, create the model that you want to use as a reference (referred to as the referenced model). Save it in an accessible location in your project directory.
2. Configure the Referenced Model:
  • Open the referenced model and ensure that it is error-free and runs correctly on its own. All the input and output ports should be defined appropriately.
3. Set the Model Referencing Configuration:
  • In the main model, go to the "Model" menu and select "Model Settings."
  • In the "Model Settings" dialog box, navigate to the "Model Referencing" section.
  • Enable the "Enable Model Referencing" option.
  • Add the path to the referenced model's location in the "Model references path" field or use the "Add" button to browse to the referenced model's location.
4. Add the Referenced Model to the Main Model:
  • In the main model, open the "Library Browser" by clicking on the "View" menu and selecting "Library Browser."
  • In the "Library Browser," find the referenced model under the "Model Referencing" section. It should appear with the name of the referenced model file.
  • Drag and drop the referenced model block from the "Library Browser" into your main model. This block represents the entire referenced model.
5. Set Model Configuration Parameters:
  • In the main model, go to the "Model" menu and select "Model Settings."
  • In the "Model Settings" dialog box, navigate to the "Model Referencing" section.
  • Under "Model Referencing," select "This model" to indicate that you want to use the referenced model as-is.
6. Connect Inputs and Outputs:
  • Connect the input and output ports of the referenced model block in the main model to other blocks as needed. These connections define how the main model interacts with the referenced model.
7. Update Diagram:
  • Save and close the referenced model if it's open.
  • Go back to the main model, right-click on the referenced model block, and select "Update Diagram" to ensure any changes made in the referenced model are reflected in the main model.
8. Run Simulation:
  • Before running the simulation, make sure all the parameters and settings are correctly configured.
  • Run the simulation to test the integration of the referenced model within the main model.
I hope this helps!
Thanks

更多回答(1 个)

Mrutyunjaya Hiremath
Model referencing in Simulink allows you to modularize your system by breaking it into separate models that can be reused and referenced within the main model. When working with model references, it's essential to follow the correct steps to ensure that the referenced models are found and linked properly. Here's a step-by-step guide on how to reference models correctly in Simulink:
1. Save the Referenced Model:
- Before referencing a model, make sure you have saved the referenced model (`File -> Save` or `Ctrl + S`). The referenced model must be saved with a `.slx` extension.
2. Set the Model Reference Configuration Parameters:
- In the referenced model, go to `Model Explorer`.
- Under `Model Referencing`, select `Model Referencing` Configuration Settings.
- Set the `Model name` and `Model file name` to match the name of the referenced model. The `Model name` is the name used to reference the model within the main model.
3. Add Model Reference Block in the Main Model:
- Open your main model.
- Go to the `Library Browser` and find the referenced model under the `Simulink` section.
- Drag and drop the `Model` block into your main model.
4. Set the Model Reference Block Properties:
- Double-click on the Model Reference block to open its properties.
- Set the `Model name` property to the name of the referenced model (same as in the configuration settings of the referenced model).
5. Update Diagram:
- If the referenced model contains Inports or Outports, you need to connect them to the main model appropriately. If there are differences in the port configurations between the referenced model and the main model, you may need to use Signal Conversion blocks or Bus Creator/Selector blocks.
6. Update Configuration Parameters (Optional):
- In the main model, go to `Simulation -> Configuration Parameters`.
- Under `Model Referencing`, you can set options for loading and updating referenced models, depending on your requirements.
7. Save and Update Diagram:
- Save the main model (`File -> Save` or `Ctrl + S`).
- Update the diagram to ensure all changes and references are up-to-date (`Simulation -> Update Diagram` or `Ctrl + D`).
8. Check for Errors:
- Check for any errors or warnings related to the model reference. If there are errors, resolve them by verifying the configurations, connections, and settings.
Following these steps should help you correctly reference models within your main Simulink model. If you encounter any errors, carefully check the model reference configurations and update the diagrams to resolve them.

类别

Help CenterFile Exchange 中查找有关 Simulink Functions 的更多信息

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by