Find index in matrix

1 回表示 (過去 30 日間)
Chris
Chris 2011 年 9 月 17 日
I am looking to find the first value in a 1600x6 dimension matrix. Column 1 contains dates formatted as yymmdd and column 2 has times formated as mmss.
How would I find the row that contains say 100104 1012 which would be 10:12 on Oct 04 2010
I just need the row index so I can collect the rest of the values

採用された回答

David Young
David Young 2011 年 9 月 17 日
Assuming it's a numerical matrix, called M:
d = 100104;
t = 1012;
row = find(M(:,1) == d & M(:,2) == t)
If it's a cell matrix with strings, use strcmp(d, M(:,1)) etc. instead of ==.

その他の回答 (1 件)

Andrei Bobrov
Andrei Bobrov 2011 年 9 月 17 日
[~,indrow] = ismember([101004,1012],A(:,1:2),'rows')

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by