datenum question - combination of date and time
Afficher commentaires plus anciens
Hi,
I just started using Matlab to process some experimental data. Certain concentration data and the according time (HH:MM:SS) are logged in a txt file. I am able to extract a single cell (1500x1) containing all times (as said in the format HH:MM:SS). I also have a single cell containig the date (e.g. 04.04.2004). For later purposes I would like to have a vector containing serial date numbers implicitly describing time and date.
I already had some tries where I first converted the points in time to serial date numbers and later on added the converted date to the aforementioned values: Wizhout success.
What I actually especially wonder about is the following code:
test=datenum('00:05:00','HH:MM:SS')
test =
7.3450e+005
>> datestr(test,'dd.mm.yyyy HH:MM:SS')
ans =
01.01.2011 00:05:00
Shouldn't the answer be "01.01.0000 00:05:00" instead?
Thanks in advance,
bearli
Réponse acceptée
Plus de réponses (1)
Bearli Ubuku
le 4 Août 2011
0 votes
4 commentaires
Fangjun Jiang
le 4 Août 2011
cSingleDate={'21.01.2011'};
cTimeOnly={'18:05:41'; '18:06:11'};
cTime=strcat(cSingleDate{1},cTimeOnly);
cTimeNum=datenum(cTime,'dd.mm.yyyyHH:MM:SS')
Bearli Ubuku
le 4 Août 2011
Walter Roberson
le 4 Août 2011
If you have that information, why not just concatenate the parts together and skip converting to date numbers? That is, the original question implies that the desired output is the date string anyhow.
Bearli Ubuku
le 4 Août 2011
Catégories
En savoir plus sur Time Series Objects dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!