필터 지우기
필터 지우기

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 CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by