I am given a complex graphic in MATLAB where currently the values on the x axis are given in numbers from 0-800. I would like to change these values into an arbitrary range of dates on the current plot.
As an example consider the following toy problem. I plot a sine curve in the interval from -10 to 10:
x = -10:0.1:10;
y = sin(x);
fig = figure;
Now I would like to change the values on the x axis to show dates, say 01-01-2019 to 11-01-2019 (dd-MM-yyyy), i.e. the interval -10 to 10 should correspond to the time range 01-01-2019 to 11-01-2019. And I would like to do this without having to plot this function again.
The reason for this is because my orginal graphic is much more complex and so I am unable to simply do something like
t = datetime(2019,01,01) + hours(0:24*10);
x = linspace(-10,10,length(t));
which would fix the toy problem. Instead I need to somehow change the properties of the existing figure in some way.
While searching for a solution for this problem I have come accross the functions xtickformat, xticks, xlabels and the likes, but unfortunately I am still rather clueless.
Any help is much appreciated, thanks in advance!