Varying parameters During a simulation

조회 수: 14 (최근 30일)
Vinol Joy D'souza
Vinol Joy D'souza 2011년 7월 19일
Hi,
I want to change the parameters of a block when the model is running and simultaneously see the changes in the output.
For eg.I have a sine block connected to a Scope.and when i start the simulation.I want to change the frequency of the sine wave and see the corresponding frequency changed wave on the scope output.I want to do this as i want to see how my model behaves for different frequencies.
Somebody please help me in this regard....Please comment and let me know..I will be grateful to who answer my question...

채택된 답변

Arnaud Miege
Arnaud Miege 2011년 7월 19일
Also have a look at this example on the File Exchange. You can use a similar technique to change the frequency of your sine wave from the GUI while the model is running.
HTH,
Arnaud
  댓글 수: 5
Arnaud Miege
Arnaud Miege 2011년 7월 20일
You'd be better contacting the author of the file (that's not me). I provided this as an example, it's up to you to adapt it for your particular needs. Simulation is standard simulation in Simulink, GRT uses Simulink Coder to generate C code and compile it into an executable that is then run (outside of MATLAB and Simulink). Build is the process of generating that C code and compiling it into an executable.
Vinol Joy D'souza
Vinol Joy D'souza 2011년 8월 6일
Thank you very much....

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Walter Roberson
Walter Roberson 2011년 7월 19일
  댓글 수: 1
Vinol Joy D'souza
Vinol Joy D'souza 2011년 7월 19일
I want to have a gui kind of thing in the model like a frequency knob and when i vary it i should see the frequency change on the scope...

댓글을 달려면 로그인하십시오.


Fangjun Jiang
Fangjun Jiang 2011년 7월 19일
If you only want to do this with sine wave frequency, you can use a slider gain block and then use a Fcn block, y=sin(2*pi*f*t).
If you want to do this in general, follow the link that Walter provided. Do the following in your GUI callback function.
set_param(YourModel, 'SimulationCommand', 'pause');
set_param(YourBlock, parameter, value);
set_param(YourModel, 'SimulationCommand', 'continue');
  댓글 수: 2
Walter Roberson
Walter Roberson 2011년 7월 19일
Under what circumstances would one need to command an 'update' after set_param() ? Are there circumstances under which doing so would mess up what one is already doing?
Fangjun Jiang
Fangjun Jiang 2011년 7월 19일
Here is a link http://www.mathworks.com/help/toolbox/simulink/ug/brbj30f.html. The most relevant info is in the paragraph started with "A tunable parameter" and the one after. In 2010b, it is much easier to find the related information.
Basically, if a block parameter can be changed through parameter dialog while the simulation is running, You don't need to update the model. The simulation will simply resume. For others, you'll need to update the model which means re-start the simulation. I tried. I can pause the simulation of a model. Then I can change the gain value of a Gain block but I can't change the sample time of the Gain block. In parameter dialog, those parameters are disabled (grayed out).

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Sources에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by