convert time in seconds after midnight to a certain interval
조회 수: 8 (최근 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에서 Dates and Time에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!