MATLAB: How to plot datetime against number

datetimeplot datetime

hi, I imported some data from excel file.I have two columns.One is dates and other is stocks. 'dates' column is of the form 'datetime' and 'stocks' is of the form 'double'. I just want to plot(dates,stocks) but it wont work. How can I plot dates with stocks or how to convert the dates to numeric?

Best Answer

You can plot class of datetime and double in MATLAB. Read the excel file using xlsread. Convert the columns of dates into class datetime using datetime.
t = datetime(2014,6,28) + calweeks(0:9);
y = rand(1,10);
plot(t,y);
Read about datetime.
Related Question