MATLAB: Plotting dates on x-axis

cellchardoublegraphplot

Hello! I have a 339×1 cell with dates in the format (ex. : 2015-05-01, 2015-05-04), and a 339×1 double with corresponding numbers. I'm trying to figure out how to plot the data with the dates on the x axis and numbers on the Y, but it gives me an error trying to plot data from a cell. I tried using cell2mat, but that just gives me a 339×10 char which also can't be plotted. Pretty new to Matlab, would really appreciate any help!

Best Answer

You need to convert the date strings to date numbers with the datenum function, plot them as date numbers, then use the datetick function to plot them as formatted dates and times.