Clear Filters
Clear Filters

How can I add time labels to the x-axis of my plot?

1 view (last 30 days)
sample data .if i have data like this how to plot with exact date and time
with seconds give me a program
31/08/97 03:03:32
31/08/97 03:07:39
31/08/97 03:10:46
31/08/97 03:15:46
31/08/97 03:26:59
31/08/97 03:28:00
31/08/97 03:42:56
31/08/97 03:54:23
31/08/97 03:56:57
31/08/97 04:07:00
31/08/97 04:47:51
31/08/97 22:07:59
  1 Comment
dpb
dpb on 16 Apr 2014
Edited: dpb on 16 Apr 2014
See
doc datenum
doc datetick
and examples thereat
ADDENDUM:
OK at machine w/ a minute...try
>> dn=datenum(datevec(t,'dd/mm/yy HH:MM:SS')); >> plot(dn,rand(size(dn))) >> datetick('x','keeplimits','keepticks')
NB: I cleaned up the above data strings that had tab here and there down to a single space; use format as needed for the actual form.

Sign in to comment.

Answers (1)

Ralf
Ralf on 16 Apr 2014
I hope it is clear now:
DateTime{1,1} = '31/08/97 03:03:32'; %
DateTime{1,2} = '31/08/97 03:07:39'; %
Yvalue = [3 4]; % Example values
ts1 = timeseries(Yvalue,DateTime); % Create a timeseries object whit oure yvalue %and the time scale
ts1.Name = 'Warming up off ... '; % Give it a name
plot(ts1); % Create a plot of it.
grid ('on');

Categories

Find more on Graphics Object Programming 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!