For hours:minu​tes:second​es.hundred​th for only seconds

Hello everybody, I have a problem in Matlab and I am not able to deal with what we have in the Mathworks site. Just look. I have an array of two columns, the first column have time data in this format 00: 00: 00.0 and I need my values are second, just 0.0s. Do you have any idea how I can solve this problem? Any help will be appreciated.

Answers (1)

Assuming that what you have is a cell array of strings:
regexprep(YourArray(:,1), '.*: *', '')
if you want the decimal form of the strings, then str2double() the result of that expression.

2 Comments

One example I have at the end of the array or value of 2 hours, 36 minutes, to 55 seconds and 1 hundredth and I need such a number: 9415,1s. The way you decided me, the numbers were repeating a one minute with the numbers in seconds, until I had done something similar but does not solve.It ended so 55.1s at the end and I needed the continuous values in time.
dv = datevec(YourArray(:,1));
dv(:,4)*60*60 + dv(:,5)*60 + dv(:,6)

Sign in to comment.

Categories

Asked:

on 27 Jul 2015

Commented:

on 27 Jul 2015

Community Treasure Hunt

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

Start Hunting!