Clear Filters
Clear Filters

Function 'subsindex' is not defined for values of class 'tf'

5 views (last 30 days)
I have been trying to work on GSO code, and it keeps showing this error I made sure there was no variable in any function called step.
Does anyone point me towards what might be wrong?
Function 'subsindex' is not defined for values of class 'tf'.
Error in UpdateLuciferin (line 28)
J(i,:)=k(2);
Error in GSO (line 34)
UpdateLuciferin; % Update the luciferin levels at glowworms’
function UpdateLuciferin
global n A J Ell gamma ro
for i = 1 : n
T = A(i,1);
K = A(i,2);
G=[0 0 0 1 0 0 0 0 0;0 0 0 0 1 0 0 0 0;0 0 0 0 0 1 0 0 0;-0.003184 0 0 0 0 -0.0199 0 0 0.0199;0 0.0002985 0 0 0 0 0 0 0;0 0 -0.000398 0.00997 0 0 -0.00997 0 0;0 0 0 0 0 0 0 0 0;0 0 0 0 0 0 0 0 0;0 0 0 0 0 0 0 0 0];
B=[0 0 0;0 0 0;0 0 0;-1 0 0;0 -0.25 0;0 0 -0.5;1 0 0;0 1 0;0 0 1];
C=[1 0 0 0 0 0 0 0 0;0 1 0 0 0 0 0 0 0;0 0 1 0 0 0 0 0 0];
D=0;
sys = ss(G,B,C,D);
i=tf(sys);
X=i(1,1);
Y=i(1,2);
Z=i(1,3);
num=[(0.6*(T^2)*K) 4.8*K*T 9.6*K];
den=[8*T 0];
tfPID=tf(num,den);
xtf=X*tfPID;
ytf=Y*tfPID;
ztf=Z*tfPID;
a=xtf/(1+xtf);
b=ytf/(1+ytf);
c=ztf/(1+ztf);
ftf=a+b+c;
y=step(ftf);
yinfo=stepinfo(y)
k=struct2cell(yinfo);
J(i,:)=k(2);
% The Matlab ’Peaks’ function is used here. Please replace it with
% the multimodal function for which peaks are sought
%J(i,:) =-(647.9-0.7276.*x+0.6765.*y-0.1455.*x.^2+0.2327.*x.*y-0.17.*y.^2+0.001928.*x.^3-0.003643.*x.^2.*y+0.00255.*x.*y.^2-0.0008596 .*y.^3+0.0001613.*x.^4-0.0002075.*x.^3.*y+(1.244e-05).*x.^2.*y.^2+(9.413e-06).*x.*y.^3+0.0001003.*y.^4);
Ell(i,:) = (1-ro)*Ell(i,:) + gamma*J(i,:);
end

Accepted Answer

Walter Roberson
Walter Roberson on 6 Mar 2018
i=tf(sys);
So i is a transfer function
J(i,:)=k(2);
That you are trying to use to index an array.
  5 Comments
Walter Roberson
Walter Roberson on 7 Mar 2018
Not unless J just happens to be a global variable that refers to a table() object which seems unlikely.
I think it is much more likely that you failed to initialize the global variable J to be a cell array before you called the function.
Pulkit Sharma
Pulkit Sharma on 7 Mar 2018
I converted the cell to a matrix to solve the problem.

Sign in to comment.

More Answers (0)

Categories

Find more on Author Block Masks 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!