Plot Price vs Time using Imported Excel Data

1 view (last 30 days)
T
T on 4 Oct 2014
Edited: Star Strider on 5 Oct 2014
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?

Answers (1)

Star Strider
Star Strider on 4 Oct 2014
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 Comments
T
T on 5 Oct 2014
I imported the dates from excel so they are in MM/DD/YYYY format.
Star Strider
Star Strider on 5 Oct 2014
Edited: Star Strider on 5 Oct 2014
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.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!