xtixks in 2d plot

23 visualizzazioni (ultimi 30 giorni)
masoumeh solgi
masoumeh solgi il 15 Mag 2020
Commentato: masoumeh solgi il 15 Mag 2020
hi,i have a problem to fix xticks in 2d plot.
i have a time series from 1990,01 up to 2020,03;when i plot my data ,the xaxis is full of date,how i could specify the date will be shown in x axis.
appreciate in advance

Risposta accettata

Rik
Rik il 15 Mag 2020
datetick seems a good place to start. Otherwise you can see if the xtickformat function suits your need.
  3 Commenti
Rik
Rik il 15 Mag 2020
The datenum values that are generated by your code didn't match what I expected, so I edited it a bit. The code below runs without errors or warnings.
S=load('example.mat');y=S.y;
startDate = datenum('01-01-1990');
endDate = datenum('01-01-2019');
xData = linspace(startDate,endDate,360);
plot(xData,y);
set(gca,'XTick',xData);
datetick('x','yyyy')
masoumeh solgi
masoumeh solgi il 15 Mag 2020
thx so much ,it works

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Dates and Time in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by