Varying parameters During a simulation

13 visualizaciones (últimos 30 días)
Vinol Joy D'souza
Vinol Joy D'souza el 19 de Jul. de 2011
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...

Respuesta aceptada

Arnaud Miege
Arnaud Miege el 19 de Jul. de 2011
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 comentarios
Arnaud Miege
Arnaud Miege el 20 de Jul. de 2011
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 el 6 de Ag. de 2011
Thank you very much....

Iniciar sesión para comentar.

Más respuestas (2)

Walter Roberson
Walter Roberson el 19 de Jul. de 2011
  1 comentario
Vinol Joy D'souza
Vinol Joy D'souza el 19 de Jul. de 2011
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...

Iniciar sesión para comentar.


Fangjun Jiang
Fangjun Jiang el 19 de Jul. de 2011
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 comentarios
Walter Roberson
Walter Roberson el 19 de Jul. de 2011
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 el 19 de Jul. de 2011
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).

Iniciar sesión para comentar.

Categorías

Más información sobre Programmatic Model Editing en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by