Converting cell data into dates that can be plotted

2 Ansichten (letzte 30 Tage)
Josh V
Josh V am 21 Jan. 2015
Kommentiert: Josh V am 21 Jan. 2015
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

Akzeptierte Antwort

dpb
dpb am 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.

Weitere Antworten (0)

Kategorien

Mehr zu Dates and Time finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by