Why am I getting an error message when simulating that says my reference model "has changed between the time when two instances of this model were compiled"?

33 views (last 30 days)
I have a top-level model that has a model reference block. I am trying to simulate all models in normal mode. If I have just one instance of the model reference, my simulation runs as expected.
I then added in a second instance of my reference model, since I want to give the same model a different input within the same top-level-model simulation.
When I run my top model, I get the following error message.
I also noticed the corners of my second model reference block have turned gray, even though they were white just before the simulation.
I am able to run my reference model with no errors at all, and only get an error message when running the top-level model after adding the second instance of this reference model block. What is causing this issue? And what do these gray corners mean?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 10 May 2018
This error could be caused by a parameter in the reference model that is changing between simulations. In this example, the reference model has a gain block where the gain parameter has been set to "randi(10)".
Using the "randi" command causes the same instance of the model to have varying parameters, which is causing the error saying that this model has changed. This can be solved by using a model argument. In the reference model, open the model's workspace by navigating to View > Model Explorer > Model Workspace. Add a MATLAB variable to the workspace, for example, "randomNum". Check the "argument" checkbox. Back in the top level model, right-click on each model reference block, and select Block Parameters. Navigate to the "arguments" tab. You will see "randomNum" as a potential argument. Here, define a value for "randomNum", such as "randi(10)". Make sure to do this for each model reference block in your top-level model.
Then, back in your reference model, set the parameter you wish to be "randi(10)" to the model workspace variable "randomNum". Then you will be able to run your top level model without this error while still using randomized parameters.
The gray corners on the second model reference signal that the model is being run in normal mode, but with normal mode visibility disabled. All instances of the model reference are part of the simulation and all are being run in normal simulation mode, but Simulink only displays one instance of the model in a model window. For the model reference with normal mode visibility (white corners), you will be able to see the display of scopes and data port values. For the model references without normal mode visibility (gray corners), you will not be able to see scopes and data port values. You can read more about normal mode visibility on the following documentation page:
https://www.mathworks.com/help/simulink/ug/simulate-models-with-multiple-referenced-model-instances-1.html

More Answers (0)

Categories

Find more on Multicore Processor Targets in Help Center and File Exchange

Products


Release

R2017b

Community Treasure Hunt

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

Start Hunting!