MATLAB: How to plot dates

dateplot

Hello,
How can I plot date in x-axis?
My csv file import dates as: '03/27/2020 19:10:35.537'
My code:
D = data{:,2};
d = datenum(D);
date = datetime(d,'Format','dd-MM-yyyy HH:mm:ss.SS','convertFrom','datenum');
As a result, I have my plots good, but only in same data (see Figure).
All my data has the same time, and have the same format 805 x 1 (double). For example, yellow line(good) and blue line (wrong) should be the same on x-axis.

Best Answer

I think we need to see your plot command to say for certain what is happening.
My recommendation would be to have your X data be the datetime variable. MATLAB is able to use that as X, and will may the XTickLabels the dates, which are easier to understand.
I would therefore use readtable to load the csv file. That way, I can import the dates directly as datetimes.