Graphics Programs Reference
In-Depth Information
ans =
3.14159e+100
Some additional text can be mixed with the numerical conversion, for
example:
>> num2str(pi,'Pi has a value of %12.5e, or thereabouts.')
ans =
Pi has a value of 3.14159e+00, or thereabouts.
The online help 9 entry for the sprintf command gives a full description
of how to use the various formatting options. (The sprintf command
is the matlab version of the C language command of the same name.)
The following table is taken from the online help.
%c Single character
%d Decimal notation (signed)
%e Exponential notation (using a lowercase e as in 3.1415e+00 )
%E Exponential notation (using an uppercase E as in 3.1415E+00 )
%f Fixed-point notation
%g The more compact of %e or %f . Insignificant zeros do not print.
%G Same as %g , but using an uppercase E
%o Octal notation (unsigned)
%s String of characters
%u Decimal notation (unsigned)
%x Hexadecimal notation (using lowercase letters a-f )
%X Hexadecimal notation (using uppercase letters A-F )
To further control the formatting, other characters can be inserted
into the conversion specifier between the % and the conversion character:
Character
What it does
A minus sign ( - )
Left-justifies the converted argument in its
field.
A plus sign ( + )
Always prints a sign character (+ or
).
Zero (0)
Pads with zeros rather than spaces.
Digits (field width)
Specifies the minimum number of digits to be
printed.
Digits (precision)
Specifies the number of digits to be printed to
the right of the decimal point.
9 Type helpdesk at the command line to get hypertext help.
Search WWH ::




Custom Search