Filter löschen
Filter löschen

Index in position 2 exceeds array bounds (must not exceed 1). Error in S=stepinfo​(ScopeData​(1:size(Sc​opeData,1)​,2)

1 Ansicht (letzte 30 Tage)
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));

Antworten (1)

Ruchika P Barman
Ruchika P Barman am 11 Jul. 2022
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.

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by