tuning paramters in referenced model whithin a Simulink Real-Time model

6 ビュー (過去 30 日間)
Yufeng Li
Yufeng Li 2025 年 1 月 10 日
回答済み: Epsilon 2025 年 1 月 17 日
Previous to R2020b, we can tune the parameter inside the model reference by the command such as:
tPar_a = getparamid(tg, 'ModelReference1/subsys1/a','Value');
setparam(tg,tPar_a,1);
After I upgrated to R2024a, the above commands are not availble anymore. I can get and set parameters of the top model, but I can not change parameter values insie the model reference and all the parameters in the model reference are not showing in SLRT_explorer neither. Is there anyway to get the parameter values in the model reference and tune them during simulink realtime simulation?

回答 (1 件)

Epsilon
Epsilon 2025 年 1 月 17 日
Hi Yufeng,
In R2024a tuning block parameters inside a referenced model is not possible, only workspace parameters, model arguments, and model instance parameters in referenced models can be tuned while the real-time application is executing.
The parameters inside a model reference can be tuned by using ‘Tuneable Global Parameters which are variables in the top model workspace or MATLAB base workspace. These can be referenced inside the model reference.
To programmatically tune using ‘setparam’, use the following syntax:
setparam(target_object, '', parameter_name, parameter_value,'Force',true)
i.e. the parameter name can be passed directly to the function ‘setparam’.
setparam function also supports dot notation syntax to access parameter values in real-time applications. 
For further reference please refer to the following documentations:
Hope it helps.

カテゴリ

Help Center および File ExchangeTarget Computer Setup についてさらに検索

製品


リリース

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by