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

5 次查看(过去 30 天)
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

采纳的回答

Walter Roberson
Walter Roberson 2018-3-6
i=tf(sys);
So i is a transfer function
J(i,:)=k(2);
That you are trying to use to index an array.
  5 个评论
Walter Roberson
Walter Roberson 2018-3-7
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Author Block Masks 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by