Simulink Real Time: Referenced Models with non-tunable configuration Arguments

12 次查看(过去 30 天)
Hello,
I'm trying to use 2 instances of a referenced model whithin a Simulink Real-Time model. Therefore, I need to run them with different parameters, so I added an Argument in the Model Workspace.
The Simulink block, where I'd like to use this Argument in the referenced model needs a non-tunable input.
Since this is just an initial ID setting that won't be changed during operation, I would be happy with the non-tunable configuration, but it seems that the System Mask Editor doesn't allow you to change this Property. At least there is no drop down menu when I click on it, as there is in the Mask Editor for Sub Systems.
Do you have any suggestions on how to work around this problem?

回答(1 个)

Kothuri
Kothuri 2024-5-25
Hi,
To use the 2 instances of the referenced model with different parameters which are non-tunable, you can
(a)Define a model argument Modelling > Model Settings > Model Properties > Model Referencing tab and add your parameters under Model arguments. For example, you might add an argument named initialID.
In the Model block (the instance of your referenced model in the parent model), specify the value for this argument in the Model arguments field found in the block's parameters. You can enter the specific value or use a workspace variable. For example: initialID=1 for the first instance and initialID=2 for the second.
With this approach you pass the initial ID setting as a non-tunable parameter since the model argument's value is set before simulation starts and cannot be changed during simulation.
(b) Use a Preload function script to set up different parameters for each instance of the referenced model by creating a MATLAB script that sets the parameters in the base workspace or model workspace before the model is loaded.
Using this script assign values to variables that correspond to the parameters in your referenced models.
Ensure this script is executed before the model runs. You can set the script to run automatically by including it in the model's Preload callback (in Model Properties under Callbacks).
You can refer the below link for more information on Model referencing
Hope this helps.

类别

Help CenterFile Exchange 中查找有关 Multicore Processor Targets 的更多信息

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by