Find a specific set of values in a matrix
5 views (last 30 days)
Show older comments
I'm trying to find some specific values from an array which has two columns
for example if one column looks like [0.1,0.2,0.5,0.6,0.1,0.9,0.1,0.3,0.2,0.5,0.1] I want the numbers >=0.2 from this column and with corresponding number in second column of the array.
0 Comments
Answers (1)
Mohammad Sami
on 13 Mar 2020
You can do this quite easily
twocolmat = rand(100,2);
idx = twocolmat(:,1) >= 0.2;
col2vals = twocolmat(idx,2);
2 Comments
Mohammad Sami
on 13 Mar 2020
If you are new to matlab, please go through the matlab onramp course.
It explains how indexing works in matlab among other things.
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!