Search for values in a matrix
2 views (last 30 days)
Show older comments
Scott Dean Seedell
on 9 Sep 2022
Edited: Walter Roberson
on 13 Sep 2022
I'd like to search the first two columns of a matrix for a specific value and then return the whole row for any that match. Thanks in advance.
0 Comments
Accepted Answer
Walter Roberson
on 9 Sep 2022
Edited: Walter Roberson
on 13 Sep 2022
mask = any(YourMatrix(:, 1:2)==SearchValue,2);
subset = YourMatrix(mask, :) ;
0 Comments
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!