time to number conversion
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have a cell array that has the following format: v0={'1/4/2011','12:17:09'} I converted the date to number using the datenum(v0(1,1),'mm/dd/yyyy'); but the question is how to convert the time '12:17:09' to a number? is it possible to merge v0(1,1) with v0(1,2) to obtain the date using timen=datenum(time,'dd/mm/yyyy HH:MM:SS')? so basically I am ok with conversing time alone to number or date & time (merged) to number. Any help is greatly appreciated
0 Kommentare
Akzeptierte Antwort
Geoff
am 22 Jul. 2012
From memory, if you use datenum to just get the time with no date, it doesn't return a number between 0 and 1. But you can get around that with mod.... So here's one option:
d = datenum(v0{1}, 'mm/dd/yyyy') + mod(datenum(v0{2}, 'HH:MM:SS'), 1);
The other way is to construct a string with both combined:
str = [v0{1}, ' ', v0{2}];
d = datenum(str, 'mm/dd/yyyy HH:MM:SS');
0 Kommentare
Weitere Antworten (0)
Siehe auch
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!