Difference between datetime values in minutes
4 次查看(过去 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?
0 个评论
采纳的回答
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]
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Calendar 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!