calendar dates in x axis
Show older comments
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
Accepted Answer
More Answers (1)
Fausto Tenini
on 7 Mar 2019
0 votes
2 Comments
Peter Perkins
on 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
on 12 Mar 2019
Categories
Find more on Calendar in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!