running a model repetitively from a m-file using sim() command

im trying to run a simulink model of pi controller through a m-file in a repetitive way.in each iteration a value of the pi parameter will be set,and the corresponding output will aslo be tabulated.in the next iteration the pi parameter will also be changed by a new values.how this can be done?

3 comentarios

What is your "repetitive way" ?
Does it mean periodically at some interval of time?
Do you want previous value of pi to calculate it's next value?
actually the overshoot,setling time,error etc. will be determined for a given set of value of pi parameter.
in the next iteration new value of pi will be set,again for those new set of values, settling time,overshoot,error will be calculated.
its for optimization.
the previous value of pi are not needed,only the settling time,overshoot,steady state error,etc.are required to be returned.when minimum output(error,over shoot,etc) will be found iteration will be stooped.that value of pi will be saved permanently

Iniciar sesión para comentar.

 Respuesta aceptada

I am not clear what exactly you want to do.
You can stop the simulation from m-file, change your parameter (pi) and start the simulation again.
To start the simulation, use
set_param(gcs,'SimulationCommand','start');
To pause the simulation, use
set_param(gcs,'SimulationCommand','pause');
To resume the simulation, use
set_param(gcs,'SimulationCommand','continue');
and To stop the simulation, use
set_param(gcs,'SimulationCommand','stop');

5 comentarios

thanks almost solved.but the thing left,is how to set the pi parameter of model,from m-file command.during running i cant go to the model.i hv to change the parameter from m-file
suppose there is a upperbound and lower bound limit of pi parameter.i hv to set the pi parameter initially to lowerbound.then the pi values will be gradually incremented by an regular interval,untill it reaches the upperbound.that is why changing the parameter from m-file is required.
You can use a constant block to hold the pi value.
When the script is running, use command
set_param('MyModel/Constant1','Value','500');
where 'MyModel/Constant1' is path of block holding pi value and 500 is the value (should be passed as string).
yes its numerical value.
pi controller is available in simulink.its a musked inbuild block.doubble clicking on it, opens a dialog box,to change the parameter.how i would use a constant bolck.
yes its numerical value.
pi controller is available in simulink.its a musked inbuild block.doubble clicking on it, opens a dialog box,to change the parameter.how i would use a constant bolck.

Iniciar sesión para comentar.

Más respuestas (0)

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by