help with plotting date/time with data
Show older comments
I'm reading some data from an excel file. The file has some heading text, so I'm loading this as,
[C,txt] = xlsread(filename);
C has 31 columns
col-1 = date,
col-2 = month,
col-3 = year,
col-4 = hour,
col-5 = min,
col-6 = sec
col-7 = mydata.
I would like to combine column 1 - 6 and write it as single 'time' as dd/mm/yyyy HH:MM:SS and plot it against 'mydata'.
My script goes, (two first lines of text removed from C)
time = [C(3:end,3) C(3:end,1) C(3:end,2) C(3:end,4) C(3:end,5) C(3:end,6)];
date = datestr(time, 'dd/mm/yyyy HH:MM:SS');
Upto here i'm getting what i need. A sample output is here:
26/03/2013 17:23:24
27/03/2013 07:13:24
27/03/2013 13:13:24
Then when I used this to plot mydata, the plot was wrong as the time axis was not correct. When i checked this with the following script just to see whether correct time is reproduced
d1 = datenum(date);
date_new =datestr(d1,'dd/mm/yyyy HH:MM:SS')
this is what i get.
03/09/0031 17:23:24
02/09/0032 07:13:24
02/09/0032 13:13:24
HH,MM and SS are correct but not the year or month or date. Workspace shows
C <4346x31 double>
d1 <4344x1 double>
date (4344x19 char>
date_new <4344x19 char>
time <4344x6 double>
Any help? Thanks.
Accepted Answer
More Answers (1)
Can you post your script u wrote for plotting your 'mydata' against time. I am having some errors in a code that works on similar principle.
I have date in column 1 and time in column 2 and data in column 3. I want to plot date/time against that data. Can anyone tell me how can I do it?
Categories
Find more on Dates and Time in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!