MATLAB: Convert milliseconds (ms) to seconds (s)

convertfloating numbermilisecondsseconds

Hello,
we have an array with stimuli onset times in milliseconds,
ms = [1600901 1970185 2340488 2710467 3080481 3449869]
and we want to convert those values to seconds with a specific format, that would be, 1600901/1000 = 1600.901.
But when I do that in MATLAB I get this result:
s = ms/1000
s =
1.0e+03 *
1.6009 1.9702 2.3405 2.7105 3.0805 3.4499
Is there a way to obtain this insead:
s = [1600.901 1970.185 2340.488 2710.467 3080.481 3449.869]
Thank you

Best Answer

You can change the format of how numbers are displayed, e.g. "shortG"
>> format shortG
>> ms/1000
ans =
1600.9 1970.2 2340.5 2710.5 3080.5 3449.9
Or "longG":
>> format longG
>> ms/1000
ans =
1600.901 1970.185 2340.488 2710.467 3080.481 3449.869
The default is "short":
>> format short
>> ms/1000
ans =
1.0e+03 *
1.6009 1.9702 2.3405 2.7105 3.0805 3.4499
Note that none of these make any difference to the numeric values stored in your array. Do not confuse how numbers are displayed with what values are stored in a variable. These are two quite different things.
Related Question