Azzera filtri
Azzera filtri

Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

mutiple reading and writing of date and time

1 visualizzazione (ultimi 30 giorni)
KRUNAL
KRUNAL il 6 Ago 2014
Chiuso: MATLAB Answer Bot il 20 Ago 2021
My data is as follows:
OriginTime Year Month Day Hour Minute Second
51.65086761 2014 6 10 12 9 5.991625
53.03222393 2014 6 10 12 9 5.991625
52.47999444 2014 6 10 12 9 5.991625
52.55764572 2014 6 10 12 9 5.991625
52.73042468 2014 6 10 12 9 5.991625
53.68612011 2014 6 10 12 9 5.991625
53.51039291 2014 6 10 12 9 5.991625
52.5239488 2014 6 10 12 9 5.991625
52.41107716 2014 6 10 12 9 5.991625
52.69466268 2014 6 10 12 9 5.991625
Here I want to 1st merge 'Hour','minute' and 'Second' column as hh:mm:ss and then add those time with the OriginTime column data I also want to merge 'Year','month' and 'Day' column data into mm/dd/yyyy. Can anyone tell me in what way should I use datestr or datevec to get the output something like
Origin Date (Local) Origin Time (Local)

Risposte (1)

Supreeth Subbaraya
Supreeth Subbaraya il 6 Ago 2014
To obtain an output like you mentioned, you can use the following code.
DateVector = [Year Month Day Hour Minute Second]
formatOut = 'mm/dd/yyyy HH:MM:SS.FFF'
datestr(DateVector,formatOut)
  2 Commenti
KRUNAL
KRUNAL il 6 Ago 2014
I know the code format. But I want to know 2 things from you.. 1st, writing DateVector = [Year Month Day Hour Minute Second] will it access year, month,day,hour,minute and Second columns in a loop? 2nd, if not i think you have not understood my question properly. I want mm/dd/yyyy in 1st column i.e Origin Date (Local) and hh:mm:ss in 2nd column i.e Origin Time (Local)
Can it be done?
KRUNAL
KRUNAL il 7 Ago 2014
Modificato: KRUNAL il 7 Ago 2014
I am trying to the following thing :
datecol(:,1) =(ofile(:,3)*1000000) + (ofile(:,4)*10000)+ (ofile(:,2));
formatOut = 'mmm.dd.yyyy';
a=datestr(datecol,formatOut)
It gives me output as:
a = Sep.3.6706
Instead of
a = Jun.10.2014
P. S : "ofile" is the filename where my above 10x7 data is stored.
Can you tel me what is wrong in the above code?

Questa domanda è chiusa.

Community Treasure Hunt

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

Start Hunting!

Translated by