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

조회 수: 8 (최근 30일)
Pulkit Sharma
Pulkit Sharma 2018년 3월 6일
댓글: Pulkit Sharma 2018년 3월 7일
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.
Pulkit Sharma
Pulkit Sharma 2018년 3월 7일
I converted the cell to a matrix to solve the problem.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Subclass Definition에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by