% 3$ 0 12 .5 b u
Identifier Conversion character
Flags
Field width Precision
Subtype
Conversion Character
The conversion character specifies the notation of the output. It consists of a single
character and appears last in the format specifier.
Specifier Description
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 zeroes do not print.)
G Same as %g, but using an uppercase E.
o Octal notation (unsigned).
s Character vector or string array.
u Decimal notation (unsigned).
x Hexadecimal notation (unsigned, using lowercase letters a–f).
X Hexadecimal notation (unsigned, using uppercase letters A–F).
For example, format the number 46 using different conversion characters to display the
number in decimal, fixed-point, exponential, and hexadecimal formats.
A = 46*ones(1,4);
txt = sprintf('%d %f %e %X', A)
txt =
'46 46.000000 4.600000e+01 2E'
Formatting Text