MATLAB: Is the precision different for the same variable when copied from the Array Editor and when displayed on the MATLAB command prompt

MATLAB

Executing the following code
x=1/3
leads to the output
x =
0.3333
However subsequently copy-pasting the value of x at the command prompt to a text editor gives the following number:
0.333333333333333
I would like to know why there is a difference in the precision.

Best Answer

The apparent difference in precision is due to the selected Display Format for the Variable Editor and the Command Window.
The default display format is 'short'. This is a Scaled fixed point format, with 5 digits. The display format in the Command Window can be changed using the FORMAT function.
For example, entering
FORMAT long
at the MATLAB  Command Window changes the format to 'long', a scaled fixed point format, with 15 digits for double; 7 digits for single.
The display format in the Variable Editor can be changed by selecting the Variable Editor Window, navigating to 'View -> Number Display Format' and selecting the desired format from a list.
It should be noted that the FORMAT function affects only how numbers are displayed, not how MATLAB computes or saves them.
For a list of display format options, usage details and examples, please refer to the documentation by typing ‘DOC FORMAT’ at the MATLAB  Command Window.