How do I find an element in a matrix that meets a condition then call its entire row?
1 view (last 30 days)
Show older comments
I'm using the delaunayTriangulation function and I'm trying to get all of the neighboring vertices(which should be the row of DT.ConnectivityList) of a specific vertex. I know how to use find but I'm unclear on how to find out what row that element is in.
0 Comments
Accepted Answer
Star Strider
on 14 May 2015
Use find with two output arguments:
N = ...;
[r,c] = find(DT==N);
This is the easiest way, especially if you don’t know the column the value you want is in. Here, ‘r’ is the row and ‘c’ the column of every occurrence of ‘N’.
More Answers (1)
Walter Roberson
on 14 May 2015
[row, col] = find(ArrayOfLogicalValue);
for example,
[row, col] = find(YourArray > 3 & YourArray<5);
See Also
Categories
Find more on Matrix Indexing 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!