convert time in seconds after midnight to a certain interval
3 ビュー (過去 30 日間)
古いコメントを表示
Given the time in seconds after midnight and an interval of what minutes it needs to be rounded to. So for example, if the output of like a datestr function gave 02:07 and my interval was 5 I would need it to be 02:05. How would I do this?
1 件のコメント
Mathieu NOE
2020 年 11 月 9 日
hi you need to make modulo(5) of the seconds
seconds_rounded = seconds - mod(seconds,5)
回答 (1 件)
per isakson
2020 年 11 月 9 日
The script
%%
obj = duration( 0, 0, 2*3600+7*60 );
obj - mod( obj, minutes(5) )
outputs
ans =
duration
02:05:00
>>
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Operators and Elementary Operations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!