MATLAB: Getting parts of Matrix based on condition imposed on elements of first column

extract parts of matrix

I want to extract part of a matrix based on condition imposed on elements of first column. For example, I have a matrix A=[10, 1,2,3; 15,2,4,6;20,3,6,9;25,4,8,12;30,5,10,15;35,6,12,18]; I want to extract columns 2 to end where elements of first column must lie between 15 and 30 inclusive. My results should be [2,4,6; 3,6 ,9; 4,8,12; 5 , 10,15]; In my real world application, I have a matrix of size 10000 by 30. Any help form kind-hearted people is much appreciated. Thank you in advance for your time.

Best Answer

Try this:
A=[10, 1,2,3; 15,2,4,6;20,3,6,9;25,4,8,12;30,5,10,15;35,6,12,18]
rowsToExtract = A(:,1) >= 15 & A(:,1) <= 30
out = A(rowsToExtract, 2:end)