The best way to plot dates on the x-axis in MATLAB is to use the datenum function. Here's an example code for plotting dates on x-axis and zooming in to a portion of the graph:
main.m447 chars19 lines
In this code, we first generate some sample data with datetime values for x-axis and some random data for y-axis. Then we plot the graph using plot function. We set the x-axis label using xlabel function and use datetick function to set the format of x-axis label to 'dd/mmm'. Finally, we use zoom function to enable zooming and use xlim function to set the x-axis limits to the desired date range.
Note that xlim function uses datenum to convert the date strings into numbers that can be used for setting the x-axis limits.
gistlibby LogSnag