Formatting output in Matlab

The format function, with the following forms
format
format type
format ( ‘type’ )

is used to control how numerical data is displayed in the Command Window (only the display is affected, not how MATLAB computes and stores numerical data). The first form changes the output format to the default appropriate for the class of data being used; the second changes the format to the specified type; and the third form is the function form of the syntax.

Example

>> pi

ans =

    3.1416

>> single(pi)

ans =

    3.1416

>> format long % changing format
>> pi

ans =

   3.141592653589793