MATLAB Answers

Updating Simulink Block Parameters using Matlab Scripts

2 ビュー (過去 30 日間)
Karthik SP
Karthik SP 2020 年 1 月 8 日
回答済み: Fangjun Jiang 2020 年 1 月 8 日
I am working on an application which involves me to write a script to automatically launch a Simulink Code and Run it.
I am able to load the model and run it using the 'Sim' command. I am also able to initialize parameters of the blocks using the 'set_param' command.
What I am not able to do is to change the values of these parameters dynamically while the Simulink Model (with end time as inf) is running? Is there a way to implement this?
cd C:\Users\INSL-CustED01\Desktop;
Starts running the Model which has a Sine Wave Block with a Scalar 'Offset' being added to it. The model starts with an offset of 10. Now, I want to write additional commands to dynamically change the Value of Offset while the Model is running.

  0 件のコメント

サインイン to comment.

回答 (1 件)

Fangjun Jiang
Fangjun Jiang 2020 年 1 月 8 日
set_param(YourModel, 'SimulationCommand', 'pause');
set_param(YourBlock, parameter, value);
set_param(YourModel, 'SimulationCommand', 'continue');

  0 件のコメント

サインイン to comment.

サインイン してこの質問に回答します。




Translated by