MATLAB Answers

Thar
0

Change the time format ?

Asked by Thar
on 9 Apr 2019
Latest activity Commented on by madhan ravi
on 10 Apr 2019
Hi!
I have the following time format:
80057
81409
91502
102514
and i want to take the format:
8:00:57
8:14:09
9:15:02
10:25:14
Any ideas?

  0 Comments

Sign in to comment.

1 Answer

Bob Nbob
Answer by Bob Nbob
on 9 Apr 2019
 Accepted Answer

I'm assuming that you have an array of doubles. This works fine for the inputs, but will not be possible with the outputs. I am outputting the results as string, therefore.
A = [80057
81409
91502
102514];
B = num2str(A,'%06d');
C = repmat(':',size(B,1),1);
B = [B(:,1:2),B_1,B(:,3:4),B_1,B(:,5:6)];

  3 Comments

madhan ravi
on 9 Apr 2019
Bob: I think you meant:
B = [B(:,1:2),C,B(:,3:4),C,B(:,5:6)]
Bob Nbob
on 9 Apr 2019
Yes, sorry. That was a hold over from some other testing I was doing.
madhan ravi
on 10 Apr 2019
+1, no need to be sorry Bob, I liked your solution though ;)

Sign in to comment.