Plotting a graph of a date !!
Afficher commentaires plus anciens
I am trying to plot a graph of the amount of rain over one year ( 12 months) using the code below, but the problem is that only 3 months appear on the graph ( Jan, Feb and March) and I have no I idea where I went wrong !!
startDate = datenum('Oct 1991');
endDate = datenum('Sep 1992');
xData = linspace(startDate,endDate,12);
plot(xData,Max_rain)
datetick('x','mmm')
Réponse acceptée
Plus de réponses (1)
Peter Perkins
le 12 Jan 2017
In recent versions of MATLAB (since R2014b), do this:
>> t = datetime(1991,10,1) + calmonths(0:11)
t =
1×12 datetime array
Columns 1 through 9
01-Oct-1991 01-Nov-1991 01-Dec-1991 01-Jan-1992 01-Feb-1992 01-Mar-1992 01-Apr-1992 01-May-1992 01-Jun-1992
Columns 10 through 12
01-Jul-1992 01-Aug-1992 01-Sep-1992
>> x = 1:12;
>> plot(t,x)
Catégories
En savoir plus sur Dates and Time dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!