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

20 ビュー (過去 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 Center および File ExchangeSimulation, Tuning, and Visualization についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by