Reputation: 35
I have a vector of time values in hh:mm
format as well as a vector of values representing levels of activity.
For example:
x=[06:18, 07:58, 08:38, 09:18, 10:58];
y=[14, 28, 33, 68, 24];
Is it possible to plot a graph of y vs. x
in Matlab?
If not, is there a way to display a vector of EPOCH time values as time in the format hh:mm
, on the graph?
For example:
x= [1383260400, 1383261000, 1383261600, 1383262200, 1383262800];
y=[14, 28, 33, 68, 24];
Thanks in advance for your help
Upvotes: 1
Views: 129
Reputation: 2256
You could also change the TickLabels
. This does not require Time Series object
time={'06:18', '07:58', '08:38', '09:18', '10:58'};
data=[14, 28, 33, 68, 24];
plot(data)
set(gca,'XTickLabel', time)
Upvotes: 2
Reputation: 564
This should do the trick:
time={'06:18', '07:58', '08:38', '09:18', '10:58'};
data=[14, 28, 33, 68, 24];
ts = timeseries(data,time);
ts.TimeInfo.Format = 'HH:MM';
ts.TimeInfo.StartDate = '00:00';
plot(ts)
The time stamps must be in a cell array and apart from that it should be pretty self explanatory.
If you would like to plot more lines in the same plot and the same time stamps just use a matrix instead of a vector for the data:
data=[14, 28, 33, 68, 24; 7, 14, 35, 34, 12];
Upvotes: 3