MATLAB: How to plot a date along the x-axis

datetimeMATLABplottable

Hi! I have 2 sets of data that shows temperature over a long period of time. I am trying to plot a graph with dates along the x-axis.
I have shortened the data as my original table has hundreds of points, but one is a table formatted like this:
Country M/DD/YY M/DD/YY M/DD/YY
———- ——- —— ——
{CountryA} 15 18 20
{CountryB} 17 22 25
{CountryC} 16 19 22
where the date is formatted in the table's column variable.
Another is a table like this:
Date Temperature
—– ———–
{'M/DD/YY'} 20
{'M/DD/YY'} 22
{'M/DD/YY'} 24
where the date is formatted inside a cell in the first column of a table.
I'm assuming it has something to do with the x-ticks and datetime functions, but I can't seem to get my 'start' point as my first date and my last point as the last point in my data. As this is being updated daily, this last point keeps changing.

Best Answer

I would suggest taking table 1 and transposing it so that your countries are your column headers, and dates are all in a column.
Convert all dates to datetimes.
Then just plot as you normally would with your dates as the X values. They will appear as datetimes in the plot.
If you want to adjust the display format, use xtickformat.