How do i find a row which follows conditions in colom a and b?

1 回表示 (過去 30 日間)
Tessa
Tessa 2014 年 11 月 25 日
コメント済み: Tessa 2014 年 11 月 25 日
Hey
I have a cell array (1000x2 cell) with colom a = dates(strings) and b=hours (numbers). Now I would like to find a the row with a certain date and hour=12. So far I made this
K>> start=find(strncmpi(A(1),[time{:,1}],8))&find([time{:,2}] == 12); Error using & Inputs must have the same size.
K>> start=find(strncmpi(A(1),[time{:,1}],8))&&find([time{:,2}] == 12); Operands to the and && operators must be convertible to logical scalar values.
Which character do I need to use to make this work??
Thanks! Tessa

採用された回答

Orion
Orion 2014 年 11 月 25 日
編集済み: Orion 2014 年 11 月 25 日
Hi,
I guess your cell array (1000x2 cell) is time.
Not knowing hat are all your data (A,time), I can just guess :
time = {...
'01022014' , 8;...
'05072014' , 12;...
'12062014' , 3};
a = time(:,1);
b = cell2mat(time(:,2));
A = '05072014';
H = 12;
start = find(strncmpi(A,a,8) & b==H);
  1 件のコメント
Tessa
Tessa 2014 年 11 月 25 日
Perfect! Thank you so much :)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeElementary Math についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by