MATLAB Answers

mr mo
0

Special selecting rows of a matrix

Asked by mr mo
on 18 Dec 2017
Latest activity Commented on by 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.

  0 Comments

Sign in to comment.

1 Answer

Answer by Roger Stafford on 18 Dec 2017
Edited by Roger Stafford on 18 Dec 2017
 Accepted Answer

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.

  1 Comment

mr mo
on 19 Dec 2017
Thanks a lot.

Sign in to comment.