Converting cell data into dates that can be plotted
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti

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 Commenti
Risposta accettata
dpb
il 21 Gen 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.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Dates and Time in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!