int2str
Convert integers to characters
Syntax
Description
Note
string
is recommended over
int2str
for combining numeric scalars with text. Use
the + operator to combine strings and numeric values for improved
readability. For additional information, see Alternative Functionality.
chr = int2str(
treats
N
)N
as a matrix of integers and converts it to a character
array that represents the integers. If N
contains floating-point
values, int2str
rounds them before conversion.
Examples
Input Arguments
Tips
int2str
returns character arrays only. Starting in R2016b, you can convert numeric arrays to string arrays using thestring
function.
Alternative Functionality
Update code that makes use of int2str
to combine numeric scalars
with text to use string
instead. Numeric values can be
combined with strings using the +
operator. Note that
string
does not truncate floating-point values. For
example:
Not Recommended | Recommended |
---|---|
newstr = ['The value is ' int2str(4.5)] newstr = 'The value is 5' |
newstr = "The value is " + round(4.5) newstr = "The value is 5" |
Extended Capabilities
Version History
Introduced before R2006a