Difference between datetime values in minutes

2 ビュー (過去 30 日間)
Tycho Maas
Tycho Maas 2020 年 12 月 30 日
コメント済み: Ameer Hamza 2020 年 12 月 30 日
Hi,
I need some help. I have an array with multiple columns and with in one of these columns dates+times as a datetime format, this array is linked as data_combined.mat. The array looks like this:
06-Dec-2020 00:04:00 '06-Dec-2020' 7 76.8566666666667
06-Dec-2020 00:20:00 '06-Dec-2020' 6.30000000000000 77.6833333333333
06-Dec-2020 00:40:00 '06-Dec-2020' 5.10000000000000 78.7166666666667
I need help calculating the difference between the datetimes in minutes and creating a column containing these values. For example, this is what the above array would then look like:
1 06-Dec-2020 00:04:00 '06-Dec-2020' 7 76.8566666666667
17 06-Dec-2020 00:20:00 '06-Dec-2020' 6.30000000000000 77.6833333333333
37 06-Dec-2020 00:40:00 '06-Dec-2020' 5.10000000000000 78.7166666666667
Can anybody help me writing some code to do this?

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 12 月 30 日
Try this
col = minutes([all_combined_short{:,1}].'-all_combined_short{1,1})+1;
all_combined_short = [num2cell(col), all_combined_short]
  2 件のコメント
Tycho Maas
Tycho Maas 2020 年 12 月 30 日
That works, thanks!
Ameer Hamza
Ameer Hamza 2020 年 12 月 30 日
I am glad to be of help!

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by