MATLAB Functions Help Desk

format

Purpose

Control the output display format

Syntax

MATLAB performs all computations in double precision.The format command described below switches among different display formats.

Description

Command

Result

Example

format

Default. Same as short.

format short

5 digit scaled fixed point

3.1416

format long

15 digit scaled fixed point

3.14159265358979

format short e

5 digit floating-point

3.1416e+00

format long e

15 digit floating-point

3.141592653589793e+0 0

format short g

Best of 5 digit fixed or floating

3.1416

format long g

Best of 15 digit fixed or floating

3.14159265358979

format hex

Hexadecimal

400921fb54442d18

format bank

Fixed dollars and cents

3.14

format rat

Ratio of small integers

355/113

format +

+,-, blank

+

format compact

Suppresses excess line feeds.

format loose

Add line feeds.

Algorithms

The command format + displays +, -, and blank characters for positive, negative, and zero elements. format hex displays the hexadecimal representation of a binary double-precision number. format rat uses a continued fraction algorithm to approximate floating-point values by ratios of small integers. See rat.m for the complete code.

See Also

fprintf, num2str, rat, sprintf, spy



[ Previous | Help Desk | Next ]