Table Of Contents

sprintf

Version:
    Last Modified: March 15, 2017

    Formats the input data as a string.

    Syntax

    str = sprintf(format, a)
    str = sprintf(format, b, ...)

    Inputs

    format

    Format you want to apply to a or b. format must use appropriate format specifier syntax. format is a string.

    a

    Data you want to format as a string. sprintf(format, a) applies a format until all data in a is formatted or an error occurs. If a is a 2D matrix, MathScript formats a in column-wise order. a is a double-precision, floating-point number, a string, or a 1D or 2D matrix of those data types.

    b

    Data you want to format as a string. sprintf(format, b, ...) formats the input data based on the corresponding format specifier. If you specify b and further parameters, the number of specifiers in format must match the number of the data elements in b and in further parameters. b is a double-precision, floating-point number, or a string.

    ...

    Further scalars or strings. If you specify b and further parameters, the number of specifiers in format must match the number of the data elements in b and in further parameters. b is a double-precision, floating-point number, or a string.

    Outputs

    str

    a or b as a formatted string.

    STR = sprintf('This is %4.2d', 123.3455655)
    STR = sprintf('%s is %4.2f', 'This', 123.3455655)

    Where This Node Can Run:

    Desktop OS: Windows

    FPGA: This product does not support FPGA devices


    Recently Viewed Topics