MATLAB: How to display the date on a plot

datedisplacementinsarradarremote sensingtime

Hi! I'm working on a plot to show the displacements of a point at different times and I got the following:
I got the results I wanted on the plot but instead of showing the time in julian time, I want to show the date. I tried converting the time vector using the datestr command but it says that there is a subscript mismatch. Can someone help me with this? Thank you.

Best Answer

If you have roughly R2015b or later (I would need to recheck the exact release) then where you have roughly
plot(Time, Displacement)
change that to
TimeDT = datetime(Time, 'ConvertFrom', 'juliandate', 'Format', 'yyyy-MM-dd'); %or as appropriate for format you want displayed
plot(TimeDT, Displacement)
The ability to use datetime objects as the "x" values did not start with R2014b with the rest of the Handle Graphics 2 (HG2) graphics system, so if you are in the R2014b to R2015b range possibly it was not yet available.
Related Question