How to save value from simulation to 3-d matrix?
Show older comments
Hi,
I've some problem with program below. I have to make an algorithm that will set PID parameters from, for exmpl -X% to +X% of basic value of P, I, D, with some quant. Whole model (PID controler with closed feedback loop) and simulation is executed in simulink. I only have to save ISE and IAE (Integrates Square of the Error, Integrates Absolute Error) as a result of simulation with changed parametrs in my matrix. I made smth like this:
P1=0.9*P; % -10% of P
P2=1.1*P; % + 10% of P
P3=P2-P1; %
P4=P3/2; % quant
I1=0.9*I; % -10% of I
I2=1.1*I; % + 10% of I
I3=I2-I1; %
I4=I3/2; % quant
D1=0.9*D; % -10% of D
D2=1.1*D; % + 10% of D
D3=D2-D1; %
D4=D3/2; % quant
for P=P1:P4:P2
for I=I1:I4:I2
for D=D1:D4:D2
i=1:length(P1:P2);
j=1:length(I1:I2);
k=1:length(D1:D2);
sim('PID_model');
M(i+j+k)=ISE
M=M+ISE
end
end
end
The problem is that in 3-d matrix, value ISE is not a changing vallue depended from P,I,D combination, but some diferent number and they are in 1-d matrix only and not saving in sequentially increased cell of matrix. Can some one help to figure out this problem? Is it bad matrix conception or loop shouldn't be based on P,I,D parameters? P.S. When I type only ISE and not assigned do 3-d martix it is showed as 1x1 vector, with changing numer and it is correct value for P,I,D combination, checked in single simulation.
Answers (0)
Categories
Find more on PID Controller Tuning in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!