MATLAB Answers

C Zeng

How to plot timeline in matlab?

Asked by C Zeng
on 16 Aug 2012

Hi, all,

I want to plot a figure with x-axis is timeline, for example, from 9am to 11pm, and every 10 or 15 minutes are one epoch. Does matlab provide some code for a timeline axis? Thanks.




No products are associated with this question.

1 Answer

Answer by Oleg Komarov
on 16 Aug 2012
 Accepted answer
% Create dates as serial numbers
serdates = fix(now) + 9/24 :  1/(24*4) : fix(now) + 11/24;
% plot
% Set ticks to serial dates (just to make sure they fall on serdates)
% Format into time 


Azzi Abdelmalek
on 16 Aug 2012

Oleg, why fix(now)?

 serdates = 9/24 :  1/(24*4) : 11/24; 

is fine

Oleg Komarov
on 17 Aug 2012

If you wanna plot for multiple days you have to start somewhere, I chose now().

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!