Discover MakerZone

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

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

Importing time values into matlab in format hh:mm without converting to demical

Asked by John on 11 Feb 2012
Latest activity Edited by dpb on 8 Oct 2013

Hello,

How can you import time values in the format hh:mm (i.e. 09:31 21:13) in a text file into matlab?

When I load like them in using this command, they get converted to decimal.

time=load('time.txt');

I also would like to plot a histogram of them.

Many thanks

John

2 Comments

per isakson on 11 Feb 2012

Does the file consist of *one* line with *many* character strings of the format "hh:ss", which are separated by *one* space?

John on 12 Feb 2012

Hello,

The file is a text file consisting of one one column of 'time' values like this:

10:43
08:23
19:56
20:29
01:33

Thank you for the help

John

Products

No products are associated with this question.

1 Answer

Answer by Walter Roberson on 11 Feb 2012

Do not use load() for this.

I do not know if importdata will work.

You can use textscan()

4 Comments

John on 11 Feb 2012

Hello,

Thank you, apologies but I'm only learning how to use matlab.

What would the correct syntax be for this problem using textscan()

Many thanks

Walter Roberson on 11 Feb 2012

We would need to know the format of the lines in order to show you the textscan() format. The link Elige posted should give you some ideas.

John on 12 Feb 2012

Hello,

I looked at that link but that poster was importing dates and time and some other date, I just have times.

The times are all in one column in this format

12:57:00
15:19:00
08:07:00
10:36:00

I'm sorry if it an easy question but I just don't know what to type.

Thank you

Walter Roberson

Contact us