Converting cell data into dates that can be plotted
8 views (last 30 days)
Show older comments

This may be a very trivial question, but I am new to Matlab and have very little experience. I have data shown in the image. Column 1, 2 and 3 collectivley form a date, and Column 4 is the price on that specified date.
I want to be able to plot price against date, but have no idea how I would transform the data I have so that I can use those dates along the x-axis. Many of the other examples I have found show how it is done using regularly spaced dates, however these dates are irregularly spaced.
Any advice would be appreciated.Thanks
0 Comments
Accepted Answer
dpb
on 21 Jan 2015
Nothing says values have to be uniform; those examples must be generating a date series rather than converting given dates. Assume you read the data into an array, X via xlsread, then
dn=datenum(x(:,3),x(:,2),x(:,1)); % args are yr, mo, day as req'd
Now plot against the datenum. If you have the latest versions there's a builtin set of time-aware plotting methods, if earlier then use datetick after plotting to set the x-axes characteristics as desired.
More Answers (0)
See Also
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!