How to put the parameter of a controller as an increasing variable, so that after each simulation it increases itself and simulates automatically. I do not want to enter a value each single time manually and wait for the simulation.

I have a PI2DOF Controller. I want to check the results(scope) with different I- Parameters of the Controller. For example from (0.1 to 3.0). How can I put this Parameter as an increasing variable, which increases by 0.1 after each Simulation? I cannot enter each value manually after each Simulation. I want to see the difference in the behaviour with all These 0.1 to 3.0 I- Parameters of the Controller. Please help!

Answers (1)

The parameter you want to test should be taken from the workspace, then you could run the simulation in a for loop in a matlab code using the sim command http://www.mathworks.com/help/simulink/ug/using-the-sim-command.html
after that you could just plot the data you need with the hold all command.
Besides that simulink has some good tolls using the PID Tune controller to examine the gain, you main want to test those.

6 Comments

Hi Naty,
Thanks for your time and your answer. Let me see if I understood this correctly. I would appreciate your words on this.
Suppose I want to simulate the model with different integral gains of PI2DOF from 0.1 to 0.9. I put a variable Name for Integral gain (Suppose KI) and define the KI as a structure in my work space. Then I use the command SimOut and write ('model','KI',0.1,'KI',0.2,'KI',0.3, .......,'KI',0.9) Does this command Change the value given in the structure (Variable for Integral gain?
Thank you!
P.S: My simulink is connected with a Hardware in the Loop. I should unfortunately tune it myself based on the System. Right now, I am checking to see why my SIMULINK model acts different than the physical model
Hi Matina,
I am uncertain if what you suggested works. I think it might be simplier using the following block to change value: http://www.mathworks.com/help/simulink/slref/fromworkspace.html
Naty
Hey Naty,
This made me a bit more confused. In which part and how is this simin block useful in my case? All I Need is an increasing Parameter as my Integral gain of the Controller. I hope my questions would not bother you! Your help is highly appreciated.
Best Regards, Matina
Hey, This is for the case if you PID control parameters are external, you can also make them internal and just write in the Integral place some variable name and change it between each run in the workspace.
e.g for internal case
Int_vec=[0.1:0.1:0.9];
for i=1:1:length(Int_vec)
I=Int_vec(i)
Data=sim('model')
figure;
plot(Data.something)
end
where "I" is the variable in the PID Integral parameters.
Hey Naty,
Thank you a lot. The model works now. However, we are not right now certain what to put as SOMETHING for the plot command. To explain a bit further, we brought the variable to the Workspace with SIMOUT. When we use plot(Level1), which is our variable which we like to see. We get for 0.1 to 0.9 ten independant plots. We actually would like to have all of them in one plot to compare the behaviours.
Thanks a lot again.
Hey Naty .. I got the answer!!!! thanks a lot! You helped me a lot ... :)

Sign in to comment.

Products

Asked:

on 3 Feb 2016

Community Treasure Hunt

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

Start Hunting!