Select matrix rows based on criteria
17 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuesta aceptada
Matt Tearle
el 3 de Oct. de 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 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Surface and Mesh Plots en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!