convert date to number

4 Ansichten (letzte 30 Tage)
Mathis Faure
Mathis Faure am 15 Mär. 2020
Bearbeitet: Star Strider am 15 Mär. 2020
Hi,
I want to convert this : 00:01:36.480
HH:MM:SS.fff where f is a millisecond
into this number 000136480
is it possible?
my version of matlab R2019b
thank you
  3 Kommentare
Mathis Faure
Mathis Faure am 15 Mär. 2020
it's a date forma I think, and I want to convert it into an integer.
Mathis Faure
Mathis Faure am 15 Mär. 2020
I think that is a character aray

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Star Strider
Star Strider am 15 Mär. 2020
Bearbeitet: Star Strider am 15 Mär. 2020
This appears to do what you want:
This = '00:01:36.480';
NowThis = datetime(This, 'InputFormat','HH:mm:ss.SSS', 'Format','HHmmssSSS')
producing:
NowThis =
datetime
000136480
EDIT — (15 Mar 2020 at 14:51)
To get a character array output:
This = '00:01:36.480';
NowThis = string(datetime(This, 'InputFormat','HH:mm:ss.SSS', 'Format','HHmmssSSS'))
ThisStr = sscanf(NowThis, '%s')
producing:
ThisStr =
'000136480'

Kategorien

Mehr zu Dates and Time finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by