calendar dates in x axis
Afficher commentaires plus anciens
I have this code (where asset simulation is a variable):
plot(asset_simulation,'-','color','green')
dateFormat = 12;
datetick('x',dateFormat)
In which way can I insert a starting date for x axis, for example today's date (going into the future, linked to the size of asset simulation variable) instead of Jan00?
thanks a lot
Fausto
Réponse acceptée
Plus de réponses (1)
Fausto Tenini
le 7 Mar 2019
0 votes
2 commentaires
Peter Perkins
le 11 Mar 2019
In versions of MATLAB since about R2016b, you are probably better off plotting using datetimes:
asset_simulation = 1:20;
xdates = datetime('today') + calweeks(0:length(asset_simulation)-1);
plot(xdates, asset_simulation, '-o');
xax = get(gca,'XAxis');
xax.TickLabelFormat = 'MMMdd';
Fausto Tenini
le 12 Mar 2019
Catégories
En savoir plus sur Calendar 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!
