Info

This question is closed. Reopen it to edit or answer.

Time series plots for a Project: Urgent

1 view (last 30 days)
sandeep Gilalla
sandeep Gilalla on 23 Apr 2015
Closed: MATLAB Answer Bot on 20 Aug 2021
I have a Speed and time stamp huge data sets. Speed is in numeric but time stamp is in char. I would like to plot speed vs time stamp. My x axis should have the format 'mm-year'. can I also know how to adjust the intervals on x axis in matlab.
for an example: Speed=[ 20 30 50 60]; Timestamp= [ 12-Dec-2014, 12-Jan-2015, 12-Feb-2015, 12-Mar-2015]; (its in char)
Now I would like to plot Speed vs Time stamp, with my x labels to be in mm-year. How can I do this????

Answers (2)

Star Strider
Star Strider on 23 Apr 2015
This works:
Speed=[ 20 30 50 60];
Timestamp= ['12-Dec-2014'; '12-Jan-2015'; '12-Feb-2015'; '12-Mar-2015'];
dnv = datenum(Timestamp, 'dd-mmm-yyyy');
figure(1)
plot(dnv, Speed)
datetick('x', 'mm-yyyy')
grid

Peter Perkins
Peter Perkins on 24 Apr 2015
Another option, if you are using MATLAB R2014b or later, is this:
Speed = [20 30 50 60];
Timestamp = ['12-Dec-2014'; '12-Jan-2015'; '12-Feb-2015'; '12-Mar-2015'];
Time = datetime(Timestamp);
plot(Time,Speed,'DatetimeTickFormat','MMM-yyyy')
This makes a plot that can be panned and zoomed.

Community Treasure Hunt

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

Start Hunting!