Plot Price vs Time using Imported Excel Data

1 次查看(过去 30 天)
Hello. I have an excel spreadsheet with two sheets that have two columns; one for price and another for date.
I was able to import the data into MATLAB using
nflx = importdata('nflx.xlsx');
I am trying to plot date on the X-axis and price on the Y-axis. I can load the data for the Y-axis, however attempting to load the data for the X-axis returns an error that cell cannot be converted to double.
How do I go about plotting the date on the X-axis?

回答(1 个)

Star Strider
Star Strider 2014-10-4
Plotting the date is relatively straightforward with the datetick function.
The difficult part is getting from your cell array of dates and MATLAB date numbers, because we don’t know what format they are in as you imported them.
  2 个评论
T
T 2014-10-5
I imported the dates from excel so they are in MM/DD/YYYY format.
Star Strider
Star Strider 2014-10-5
编辑:Star Strider 2014-10-5
I apologise for the delay.
That makes it simple:
DC = {'06/02/2014'; '06/07/2014'; '07/14/2014'};
DCn = datenum(DC, 'mm/dd/yyyy');
Just use datenum directly, then datetick on your x-axis.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Calendar 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by