Finding row values given a position.

10 views (last 30 days)
After using the "find" function to get the position of a value in a matrix, how do I retreive the values in the corrosponding row?
  1 Comment
Rik
Rik on 25 Mar 2022
Did you read the documentation for find? What exact syntax are you using?

Sign in to comment.

Accepted Answer

Mathieu NOE
Mathieu NOE on 25 Mar 2022
hello
see example below :
use find with linear indices output (see the doc)
A = randn(5,3)
ind = find(A>0 & A<1)
B = A(ind)
  2 Comments
Rik
Rik on 25 Mar 2022
I interpreted the question a bit differently:
A = randn(5,3)
A = 5×3
-0.2579 -2.8261 -2.1941 0.6462 0.5321 0.3075 -0.1197 -0.2081 -0.5278 0.7857 0.4000 -0.8904 0.2132 0.4027 0.5705
[r,c]=find(A>0.7)
r = 4
c = 1
B = A(unique(r),:)
B = 1×3
0.7857 0.4000 -0.8904
Riley Heymann
Riley Heymann on 27 Mar 2022
Edited: Riley Heymann on 27 Mar 2022
yes this is it, thank you Rik

Sign in to comment.

More Answers (0)

Categories

Find more on Get Started with MATLAB 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!