Select matrix rows based on criteria
18 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have a 1000 rows by 100 column matrix. i) wish to select those rows which meet a criteria, and then use this to select the equivalent position from a second column vector. I tried to produce a column vector where if any element i n a row met or exceeded the criteria then I would get a 1 (or 0 if not). Then i planned to use this 'mask' to select from the second vector.# My problems:
criteria = >10.6 mask=(data(:))>=10.6;
returns an empty matrix. What am I missing? is there a simple way.[The second column vector could be included in the original data but must not be part of the elements evaluated against the criteria] Thanks in advance
0 Kommentare
Akzeptierte Antwort
Matt Tearle
am 3 Okt. 2011
I can't quite work out the code (maybe the formatting is confusing me), but it sounds like what you're trying to do is this:
A = magic(4)
y = (14:17)'
threshold = 13;
idx = any(A > threshold,2);
y(idx)
This selects the rows of A that contain any value greater than 13, then extracts those rows of the 4-element column vector y.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Surface and Mesh Plots finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!