Index exceeds the number of array elements (9).
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
[row,c]=size(x);
total_frames=row/9;
k=1;
i=5;
aa=rem(row,P+1); % in this case P+1=9;
last_index=row-aa;
for i=5:9:last_index %runs for tatal number of samples in signal
x =[x(i)-1, x(i)-2, x(i)-3, x(i)-4, x(i), x(i)+1, x(i)+2, x(i)+3, x(i)+4];
j=x(i);
I want this code to print the above 9 samples in J variable but it throws an error "Index exceeds the number of array elements (9)".
for r=0:(P/2)-1 % Sumation loop from formula
neighbour=x(i + (r-(P/2)));
center=x(i);
if(neighbour > center+ thresh)
b_left(r+1)=1;
elseif( (neighbour > center-thresh) && (neighbour < center+thresh))
b_left(r+1)=0;
elseif (neighbour < center-thresh)
b_left(r+1)=-1;
end
0 Kommentare
Antworten (1)
KSSV
am 28 Aug. 2020
The error is simple. You are trying to extract more than the number of elements present in the array.
A = rand(5,1) ;
A(1) % no error
A(5) % no error
A(end) % no error
A(6) % error, because there is no sixth element present in A. Only five elements.
Siehe auch
Kategorien
Mehr zu Matrices and Arrays 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!