Index in position 2 exceeds array bounds

Here is the error. Index in position 2 exceeds array bounds (must not exceed 1). Error in file00 (line 15)
mask = M(i:i+p-1, j:j+p-1); % burada 1 degeri varsa nanosheet var demektir…
——————————————————————————————————————- I try to find some part in the pics (.xqd file) and compare them to mask ( which I already mark the parts in it ). This is my code. It is written in MATLAB. I=read_afm(‘191022004.xqd’);
M=read_afm(’04.mat’); input = I(4, 1);
output= M(2, 1); sc = 1; [w, h] = size(I);
p = 32;
kon = 0;
for i=1:32:w
for j=1:32:h
piece = I(i:i+p-1, j:j+p-1);
mask = M(i:i+p-1, j:j+p-1); % burada 1 degeri varsa nanosheet var demektir…
if (sum(mask(:)) > 0)
input(:, sc) = [mean(piece(:)) max(piece(:)) length(piece(:)) min(piece(:))];
output(:, sc) = [1 0];
sc = sc + 1;

m = mean(piece(:));
s = std(piece(:));
r = max(piece(:)); (THESE ARE MY PARAMETER TO COMPARE PIECES AND MASK.)
t = min(piece(:));
v = var(piece(:));
l = length(piece(:));
r2 = rms(piece(:));
r3 = range(piece,’all’);
med = median(piece(:));
kon = kon + 1; elseif (kon > 0)
input(:, sc) = [mean(piece(:)) std(piece(:)) max(piece(:))];
output(:, sc) = [0 1];
sc = sc + 1;
kon = kon – 1;
%m = mean(piece(:));
%s = std(piece(:));
end

end
end

Answer

Leave a Comment