필터 지우기
필터 지우기

Time of day deduction

조회 수: 4 (최근 30일)
Maroulator
Maroulator 2014년 12월 10일
답변: Peter Perkins 2014년 12월 11일
I have a matrix with sequential elements from 1 to 86,400; one for every second of the day. Is anyone aware of a built-in function that would allow me to convert any given element value in this array into a figure/string that would show me the corresponding hours, minutes, and seconds (HH:MM:SS)?

채택된 답변

Star Strider
Star Strider 2014년 12월 10일
The datestr function comes quickly to mind.

추가 답변 (1개)

Peter Perkins
Peter Perkins 2014년 12월 11일
If you have access to R2014b, the new duration data type will help:
>> d = seconds(0:40:180)
d =
0 secs 40 secs 80 secs 120 secs 160 secs
>> d.Format = 'hh:mm:ss'
d =
00:00:00 00:00:40 00:01:20 00:02:00 00:02:40
>> c = cellstr(d)
c =
'00:00:00' '00:00:40' '00:01:20' '00:02:00' '00:02:40'

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by