Special selecting rows of a matrix

3 views (last 30 days)
mr mo
mr mo on 18 Dec 2017
Commented: mr mo on 19 Dec 2017
Hi. I have a matrix of size m*n.
I want to select those rows of this matrix that their value in 10th column are between 10 to 12.
How can I do that?
Thanks a lot.

Accepted Answer

Roger Stafford
Roger Stafford on 18 Dec 2017
Edited: Roger Stafford on 18 Dec 2017
Let M be the given matrix. Then do this:
p = (1:size(M,1)).';
p = p(M(:,10)<=12&M(:,10)>=10);
p will be a column vector consisting of the row indices of all rows in M in which the element of the 10th column lies between 10 and 12.

More Answers (0)

Categories

Find more on Matrices and Arrays in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!