How to do calculation on time values imported from Excel?

Hello,
I have the following values in Excel:
  • Bed time 19:34:00
  • Get up time 07:04:00
  • Time in bed 11:30:00
  • Sleep start 19:42:00
  • Sleep end 07:00:00
I want to import them into MATLAB and do some calculation on these time values such as subtraction. The time values look like this after importing:
  • 0.8153
  • 0.2944
  • 0.4792
  • 0.8208
  • 0.2917
and obviously doing calculation on them would be nonsense. Would any body help me with this issue? I have stuck with it for few days, and no progress yet.
Thanks in advance,

回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 3 月 22 日
編集済み: Azzi Abdelmalek 2016 年 3 月 22 日

0 投票

If a is your array
a=[0.8153 ,0.2944,0.4792,0.8208,0.2917]
out=datestr(a,'HH:MM:SS')

1 件のコメント

Yoolla
Yoolla 2016 年 3 月 22 日
Dear Azzi,
Thanks for the answer,
But the output is in char format, which I cannot convert it to number. How can I subtract out(1,:) from out(3,:) and have the answer in time format?

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

カテゴリ

ヘルプ センター および File ExchangeData Import from MATLAB についてさらに検索

タグ

質問済み:

2016 年 3 月 22 日

コメント済み:

2016 年 3 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by