How can I change a parameter in a Simulink block using code setVariable?
1 回表示 (過去 30 日間)
古いコメントを表示
Carlos Santiago Moreno Lozano
2021 年 1 月 20 日
編集済み: Carlos Santiago Moreno Lozano
2021 年 2 月 8 日
I do a simply circuit simulation, a voltage source DC and a resistence, i create 2 variables A = amplitude DC source and R = resistance, when try change this variables ony change A but R not change in the block so the out is not the rigth.
I do this
In = Simulink.SimulationInput('Sim');
In = In.setVariable('A',10);
In = In.setVariable('R',20);
In = simulink.compiler.configureForDeployment(In); % I need this
out = sim(In);
2 件のコメント
Rhea Chandy
2021 年 2 月 4 日
From what I understand, you're trying to update the variables 'A' and 'R' programmatically, but the variable R is not updating as expected. Can you share the model you're working on so that I can recreate the issue and investigate further?
採用された回答
Mark McBroom
2021 年 2 月 6 日
Since the variables you are trying to change are in the Model Workspace, you need to add an optional argument specifying this.
In = In.setVariable('R',2, 'Workspace', 'RL')
In = In.setVariable('A',20, 'Workspace', 'RL')
Thanks.
Mark.
1 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Electrical Sensors についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!