Effacer les filtres
Effacer les filtres

Finding values in a matrix

1 vue (au cours des 30 derniers jours)
TREDWISE
TREDWISE le 13 Fév 2015
Commenté : TREDWISE le 13 Fév 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!

Réponse acceptée

Image Analyst
Image Analyst le 13 Fév 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)
  1 commentaire
TREDWISE
TREDWISE le 13 Fév 2015
Thank you so much :-)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by