Why does the following for loop produce the error "Index in position 2 exceeds array bounds (must not exceed 1)"?
data matrix (1000×4)
x = data(:,2); y = data(:,3); tr = data(:,4); xt = x((tr)==1); yt = y((tr)==1); for i = 1:size(x) for j = 1:size(xt) if sqrt((x(1,i)-xt(1,j))+(y(1,i)-yt(1,j)))< 5 fprintf ('Pass') end end end
Best Answer