How to calculate time elapsed for AM and PM
4 ビュー (過去 30 日間)
古いコメントを表示
Hi,
I have below time array:
Start time End time
23:12:17 PM 23:12:19 PM
3:12:11 AM 3:12:29 AM
23:59:17 PM 01:10:13 AM
11:59:17 AM 13:10:13 PM
I want to calculate time elapsed between Start time to End time of each row.
0 件のコメント
回答 (2 件)
Star Strider
2018 年 3 月 19 日
You should add dates to each time, and delete the ‘AM’ and ‘PM’ since you are also using 24-hour times.
Try this:
SA = {'23:12:17' '23:12:19'
'3:12:11' '3:12:29'
'23:59:17' '01:10:13'
'11:59:17' '13:10:13'};
DA = datetime(SA, 'InputFormat','HH:mm:ss');
BT = between(DA(:,1), DA(:,2));
It will give a negative value for Row 3, because the between function does not ‘know’ they are consecutive days, since you did not tell it.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Introduction to Installation and Licensing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!