フィルターのクリア

Combining hours and minutes

7 ビュー (過去 30 日間)
012786534
012786534 2017 年 6 月 13 日
コメント済み: James Tursa 2019 年 11 月 19 日
I have a 600 x 1 double array where the hour is on the 8th row and the minutes are on the 9th row. I want to combine them into a HH:MM format. I was thinking of something like this:
out = datestr(file(8,1), file(9,1), 'HH:MM');
Which does not work obviously. Any ideas ?
Thank you

採用された回答

James Tursa
James Tursa 2017 年 6 月 13 日
If you just want to combine them into a string with the HH:MM format, e.g.,
out = sprintf('%02d:%02d',file(8,1),file(9,1));

その他の回答 (1 件)

Maria Akil
Maria Akil 2019 年 11 月 18 日
編集済み: Maria Akil 2019 年 11 月 18 日
i have mine listed as vectors, so for ex
hours=[20 00 16 12 04 09 99]
minutes=[20 30 12 18 19 25 37]
how can i combine those to the hh:mm form?
  1 件のコメント
James Tursa
James Tursa 2019 年 11 月 19 日
Does something like this work for you:
reshape(sprintf('%02d:%02d',[hours;minutes]),5,[])'

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

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by