Constant Blocks Value Change under mask

14 ビュー (過去 30 日間)
Ege Can Koçak
Ege Can Koçak 2021 年 6 月 3 日
回答済み: Tejas 2024 年 2 月 16 日
Hello,
I developed a Simulink model with lots of inputs. The model is working perfectly, however I want to make it more useful. I masked my constant blocks (12 constant blocks) and I made sliding buttons, radio buttons etc. Now I cannot change the values of constant blocks. I can move sliders and dials but they are not effect the value. I promoted their constant values but still I cannot change it. Is there anyone can help me ?
Kind regards,
Ege
  2 件のコメント
Sanman
Sanman 2021 年 6 月 7 日
Hi Ege,
Would you mind sharing your model?
Regards,
Sanman
Ege Can Koçak
Ege Can Koçak 2021 年 6 月 8 日
Hello Sanman,
Unfortunately I cannot share the model but I can briefly explain it to you. Actually it is a simple change in the model;
I have lots of constant blocks to give the model input values. I masked them together in order to make it more user friendly. I add some sliders, dials etc. to give input values before start the model. Now the sliders and dials does not change the value of the constant blocks.
Should I use any alternative for constant blocks or what can I do to change constant block's values with mask ?
Best regards,
Ege

サインインしてコメントする。

回答 (1 件)

Tejas
Tejas 2024 年 2 月 16 日
Hello Ege,
To modify the values of Constant blocks through a mask, you should begin by defining parameters that correspond to each block within the Mask Editor.
After setting up these parameters, you'll need to create a mask initialization callback. Within this callback, you can employ the 'set_paramfunction to update the values of the Constant blocks to your desired figures.
Here is a screenshot for your reference, showcasing the corresponding parameters for the constant block.
In the code section of Mask editor, create a Mask Initialization callback , and enter the following code :
function MaskInitialization(maskInitContext)
set_param( [gcb '/Constant_1'], 'Value', 'Val_const1');
set_param( [gcb '/Constant_2'], 'Value', 'Val_const2');
set_param( [gcb '/Constant_3'], 'Value', 'Val_const3');
end
Here “Constant_1”, “Constant_2”, “Constant_3” are the labels assigned to constant blocks in Simulink model.
Hope this helps!

カテゴリ

Help Center および File ExchangeProgrammatic Model Editing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by