MATLAB Answers

How to programmatically change tunable masked parameters while a simulation is running?

4 ビュー (過去 30 日間)
Jon
Jon 2020 年 10 月 8 日
コメント済み: Jon 2020 年 10 月 26 日
I would like to programmatically change masked parameters while a simulation is running. I have made the parameters "tunable" however if I attempt to change them programmatically I get the error Cannot change property 'Value' of ... while simulation is running. I can however double click on the block and change the paramaters in the mask dialog box while the simulation is running demonstrating that they are in fact tunable. Is there some way to programmatically change a tunable masked parameter while the simulation is running?
The problem is demonstrated using the attached model.
1. Start the model running
2. Double click on the Subsystem block and confirm that you can edit/change the parameter called x while the simulation is running
3. On the command line get the corresponding Simulink.Mask object using m = Simulink.Mask.get('tryparam/Subsystem')
4. on the command line type m.Parameters.tunable and confirm that it is 'on'
5. Attempt to set the tunable masked parameter using m.Parameters.Value = '5' (or any other number), you will see the error: Cannot change property 'Value' of 'tryparam/Subsystem' while simulation
is running
I have also submitted this as a support request, but in case anyone in the community has an answer I thought I would check more widely

  2 件のコメント

Jon
Jon 2020 年 10 月 8 日
Sorry I meant to attach a version with a scalar parameter value to keep it simple. Actually in the example I have a vector value, [2 5 8 9], so instead try change it to a new vector values using m.Parameters.Value = '[1 2 3 4]' or some other vector
Jon
Jon 2020 年 10 月 8 日
As a work around it seems that I can use, for example,
set_param(gcb,'MaskValueString', '[1 2 3 4]')
However I'm still wondering why setting the Simulink.MaskParameters Value property does not work when the simulation is running. It would still be preferable to do it this way as the parameters are a little better structured, and easier to index there.

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

採用された回答

Chaitanya Mallela
Chaitanya Mallela 2020 年 10 月 20 日
I have brought the issue of 'Programmatically changing the tunable masked parameters while running the model' to the notice of our developers. They will investigate the matter further.

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by