MATLAB: How to separate M*3 matrix by interval of 1

intervalmatrix

For example, If I have a data like 20*3 data, and define each of column as x y z, how can I separate matrix that the x value is 0<x<1, 1<x<2 , 2<x<3 … ??

Best Answer

One simple way is;
A = rand(20,3)*10;
for i = 0:9
At{i+1} = A(A(:,1)>i&A(:,1)<i+1,:,:); % Rows of A matrix where first columns
% values are between i and i+1
end
To access the values where i<x<i+1, you call;
At{i+1}