Borrar filtros
Borrar filtros

Finding values in a matrix

1 visualización (últimos 30 días)
TREDWISE
TREDWISE el 13 de Feb. de 2015
Comentada: TREDWISE el 13 de Feb. de 2015
Hi all,
I have a problem that I don't know quite how to describe. I am trying to find all data points that are above a certain threshold in a matrix.
[row,col]=find(TBin>=timeS(k1) & TBin<=timeS(k1+1));
Which works. It gives me the row and column coordinates of the points that meet that criteria in an array. Then I want to get the data points that correspond to those locations.
TiP=TBin(row,col);
What this gives me is a 250 x 250 matrix where all the values down a column are right, but for some reason each value is repeated 250x across all of the other columns. Is there a way to only get a single column with the correct answers? It confuses me that the output is a matrix. I know I can select only one column from the matrix but I was hoping for a more efficient way.
Thanks!

Respuesta aceptada

Image Analyst
Image Analyst el 13 de Feb. de 2015
You need to use logical indexing, not find():
logicalIndexes = TBin>=timeS(k1) & TBin<=timeS(k1+1) % k1 is a vector.
% If k1 is a vector, then logicalIndexes is also a vector.
% Extract the values
outputValues = TBin(logicalIndexes)

Más respuestas (0)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by