sprintf
Format data into a string.
Syntax
Section titled “Syntax”s = sprintf(format, A, ...)[s, errmsg] = sprintf(format, A, ...)Description
Section titled “Description”Returns a string created by formatting the input arguments according to the C-style format specification. Supports %d, %f, %e, %g, %s, %c, etc. with field-width and precision modifiers.
The optional second output errmsg contains a formatting error message (or empty string if formatting succeeded).
Examples
Section titled “Examples”sprintf('%d items at $%.2f each', 12, 3.5) % '12 items at $3.50 each'sprintf('%5d', [1 2 3]) % ' 1 2 3'