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.
You can use
>> d_char = char(d);
>> whos d_char
Name Size Bytes Class Attributes
d_char 1x8 16 char
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With