Converting cell data into dates that can be plotted

2 ビュー (過去 30 日間)
Josh V
Josh V 2015 年 1 月 21 日
コメント済み: Josh V 2015 年 1 月 21 日
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

採用された回答

dpb
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.
  1 件のコメント
Josh V
Josh V 2015 年 1 月 21 日
Thanks for your help. I've got it now.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by