フィルターのクリア

Finding values in a matrix

1 回表示 (過去 30 日間)
TREDWISE
TREDWISE 2015 年 2 月 13 日
コメント済み: TREDWISE 2015 年 2 月 13 日
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!

採用された回答

Image Analyst
Image Analyst 2015 年 2 月 13 日
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 件のコメント
TREDWISE
TREDWISE 2015 年 2 月 13 日
Thank you so much :-)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by