Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to print Matlab's DURATION

Tags:

time

matlab

Matlab has recently introduced a new type—duration. So I can do something like:

>> d = datetime('12:10:00') - datetime('12:05:00')
d = 
   00:05:00
>> whos d
  Name      Size            Bytes  Class       Attributes
  d         1x1               128  duration  

Now I'd like to output a result of some calculation, which is of duration type, using fprintf. However duration is neither a number nor a string, nor does it have a method to create a string. What can I do to make fprintf accept it?

I am with Matlab 2014b.

like image 217
texnic Avatar asked Jul 06 '15 11:07

texnic


1 Answers

You can use

>> d_char = char(d);
>> whos d_char
   Name        Size            Bytes  Class    Attributes

   d_char      1x8                16  char    
like image 60
m.s. Avatar answered Sep 21 '22 12:09

m.s.