Main Content

num2str

Convert numbers to character array

Description

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.

example

s = num2str(A,precision) converts fi object A to a character array representation using the number of digits of precision specified by precision.

example

s = num2str(A,formatSpec) applies a format specified by formatSpec to all elements of A.

Examples

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.

A = fi(pi)
A = 

    3.1416

          DataTypeMode: Fixed-point: binary point scaling
            Signedness: Signed
            WordLength: 16
        FractionLength: 13
S = num2str(A,8)
S =

    '3.1416016'

Input Arguments

collapse all

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

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.

Output Arguments

collapse all

Text representation of the input array, returned as a character array.

Version History

Introduced in R2016a