Index in position 2 exceeds array bounds (must not exceed 1). Error in S=stepinfo(ScopeData(1:size(ScopeData,1),2)
1 次查看(过去 30 天)
显示 更早的评论
hi! i just wrote the optimization code for fuzzy membership using firefly algorithm. I use this code:
%clear
clc
%inisialisasi firefly
alpha = 0.01;
beta = 0.2;
jff = 30;
iter = 0;
maxiter = 50;
errorr = 100000;
errmin = 0.001;
% posisi awal firefly
batas = [-500 -380; %E
-300 -250;
-450 -300;
-300 -180;
-50 0;
-220 -150;
-10 5;
-15050 -14950; %dE
-1000 -950;
-4950 -4850;
-5 5;
4900 4990;
500 600;
14950 15050];
for i=1:jff
for j=1:size(batas,1)
ff(i,j)=(rand*(batas(j,2)-batas(j,1)))+batas(j,1);
end
end
while errorr>errmin && iter<maxiter
iter=iter+1;
for i=1:jff
sim mppt_buck;
S=stepinfo(ScopeData(1:size(ScopeData,1),2),ScopeData(1:size(ScopeData,1),1));
bright(i,1) = mean(ScopeData(round(S.SettlingTime*1000):size(ScopeData,1),2));
bright(i,2) = S.SettlingTime;
bt(i,1) = (200-mean(ScopeData(round(S.SettlingTime*1000):size(ScopeData,1),2)))/10+S.SettlingTime;
bright;
end
ffl=ff;
for i=1:jff
for j=1:jff
for k=1:size(batas,1)
if bt(j,1) < bt(i,1)
ff(i,k)=ff(i,k)+(beta*(ff(j,k)-ff(i,k)))+((maxiter-iter)/maxiter)*alpha*(rand-0.5);
if ff(i,k)<=batas(k,1)
ff(i,k) = batas(k,1);
end
if ff(i,k)>=batas(k,2)
ff(i,k) = batas(k,2);
end
end
end
end
end
for i=1:jff
if bt(i,1) == min(bt)
kecil = i;
end
end
errorr = max(max(abs(ffl-ff)));
clear bright bt duty input eml fis2 ruleList out dduty
end
ff(kecil,:)
but in command window i just had an error like this
> In fireflybismillah (line 36)
Index in position 2 exceeds array bounds (must not exceed
1).
Error in fireflybismillah (line 42)
S=stepinfo(ScopeData(1:size(ScopeData,1),2),ScopeData(1:size(ScopeData,1),1));
0 个评论
回答(1 个)
Ruchika P Barman
2022-7-11
It is my understanding that you are getting an error because you are trying to extract a column that is not a part of the 2-D matrix and hence, you are getting this error.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!