Convert numbers to character array
s = num2str(A)
s = num2str(A,precision)
s = num2str(A,formatSpec)
example
s = num2str(A) converts fi object A into a character array representation. The output is suitable for input to the eval function such that eval(s) produces the original fi object exactly.
s
A
fi
eval
eval(s)
s = num2str(A,precision) converts fi object A to a character array representation using the number of digits of precision specified by precision.
precision
s = num2str(A,formatSpec) applies a format specified by formatSpec to all elements of A.
formatSpec
collapse all
Create a fi object, A, and convert it to a character vector.
A = fi(pi)
A = 3.1416 DataTypeMode: Fixed-point: binary point scaling Signedness: Signed WordLength: 16 FractionLength: 13
S = num2str(A)
S = '3.1416'
Create a fi object and convert it to a character vector with 8 digits of precision.
S = num2str(A,8)
S = '3.1416016'
Input array, specified as a numeric array.
Data Types: fi | double | single | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical Complex Number Support: Yes
double
single
int8
int16
int32
int64
uint8
uint16
uint32
uint64
logical
Maximum number of significant digits in the output string, specified as a positive integer.
Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64
Format of the output fields, specified using formatting operators. formatSpec also can include ordinary text and special characters.
For more information on formatting operators, see the num2str reference page in the MATLAB® documentation.
num2str
Text representation of the input array, returned as a character array.
mat2str | num2str | tostring
mat2str
tostring