Info
Questa domanda è chiusa. Riaprila per modificarla o per rispondere.
Change numerical data points to dates
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Hi,
I have a data set that returns dates in my command window, which is what I want. The dates in the return window look as follows:
02-May-0120 00:00:00
02-Jun-0120 00:00:00
02-Jul-0120 00:00:00
02-Aug-0120 00:00:00
When I try to plot these dates on my x-axis, it lists them as numerical ticks. Please see attached. How do I get the graph to display my x axis data the same as it is returned in the command window?
Thanks,
David
0 Commenti
Risposte (1)
Star Strider
il 14 Ago 2020
Neither MATLAB nor I understand ‘0120’ in what otherwise appears to be the year field in the date vector.
Try this:
datstr = {'02-May-0120 00:00:00'
'02-Jun-0120 00:00:00'
'02-Jul-0120 00:00:00'
'02-Aug-0120 00:00:00'};
Dates = datetime(datstr, 'InputFormat','dd-MMM-01yy HH:mm:ss');
Data = rand(size(Dates));
figure
plot(Dates, Data)
grid
.
0 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!