Finding values on only time (excluding date)
古いコメントを表示

3 件のコメント
KL
2017 年 10 月 5 日
How have your stored your data? which version are you using?
sikander shahzad
2017 年 10 月 5 日
sikander shahzad
2017 年 10 月 6 日
回答 (2 件)
Cam Salzberger
2017 年 10 月 5 日
1 投票
Andrei Bobrov
2017 年 10 月 5 日
T = readtable('data1.xlsx');
T.Date_Time = datetime(join(string(T{:,1:2})),'I','dd-MM-uuuu HH:mm');
T = T(:,[1,3:end]);
out = T(hour(T{:,1}) == 8,:);
2 件のコメント
sikander shahzad
2017 年 10 月 6 日
Cam Salzberger
2017 年 10 月 6 日
You generally shouldn't need to use the "find" function. It is often more efficient to just use logical indexing directly. That is what is being done with Andrei's example. The expression:
logicalArray = hour(T{:, 1}) == 8;
will produce a logical array of the same number of rows as T, with "true" whenever the hour value in the first column of T is 8. When you do:
T(logicalArray, :)
it will return only those rows that were "true" in the logical array.
-Cam
カテゴリ
ヘルプ センター および File Exchange で Dates and Time についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!