Index exceeds array bounds. Error in PID_optimized (line 14) gc = tf(K(i)*([1 2*a(j) a(j)^2]),[1 0]); %controller transfer fx Gc
Show older comments
Hi all
Trying to run this code. I am getting an error message 'index exceeds array bounds. Error in PID_optimized (line 14). The code is given below
clc
%G(s) = 1.2/0.36s^2+1.86s^2+2.5s+1
% Gc(s) = K(s+a)^2/s
% Required to test for K and a values
K = [2.0 2.2 2.4 2.6 2.8 3.0];
a = [0.5 0.7 0.9 1.1 1.3 1.5];
%evaluate closed-loop unit-response at each 'K' and 'a' combination that
%will yield the maximum overshoot less than 10%
t = 0:0.01:5;
g = tf([1.2],[0.36 1.86 2.5 1]);
K =0; %initialization
for i = 1:6
for j = 1:6
gc = tf(K(i)*([1 2*a(j) a(j)^2]),[1 0]); %controller transfer fx Gc
G =gc*g/(1+(gc*g)); %closde-loop transfer function
y = step(G,t);
m = max(y);
if m<1.10
K = K+1;
Solution(K,:) = [K(i) a(j) m];
end
end
end
solution; %print solution table
Accepted Answer
More Answers (0)
Categories
Find more on Startup and Shutdown 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!