Converting cell data into dates that can be plotted
6 次查看(过去 30 天)
显示 更早的评论

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 个评论
采纳的回答
dpb
2015-1-21
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Dates and Time 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!