MATLAB: Plot Time series data in date format

date formatplottime series

Hello,
I confused… if i have input data in .txt
exp : abc.txt
20110313000000 3.87
20110313000015 3.871
20110313000030 3.87
20110313000045 3.869 . . 20110313000130 3.844
20110313000145 3.83
20110313000200 3.824 ..
first column is date format (yyyymmddHHMMSS) and second column is the data
how if I want to plot in X axes in format '2011-March-11 00:15' (yyyy-MM-dd HH:MM)?
I write matlab
load abc.txt;
plot(abc(:,1),abc(:,2));
title('Tide time series 1116');
xlabel('time');
ylabel('Sea water level');
but it didn't give the right plot, anyone can help this basic problem.. thank you

Best Answer

You can break up the number in the first column using pure numeric ways similar to what I used in http://www.mathworks.com/matlabcentral/answers/21688-is-there-a-more-effitiant-way-than-datenum-num2str-ftstempin-1-1
And if you don't have a lot of data to input and just want to get the code done, you can instead use
x = datenum(cellstr(num2str(abc(:,1))), 'yyyymmddHHMMSS');
plot(x, abc(:,2))
datetick('x', 'yyyy-mmmm-dd HH:MM');
Note the small modification of your format, from MM to mmmm as MM is minutes but you want the month name which is coded mmmmm