Company Events Academic NI Developer Zone Support Solutions Products & Services Contact NI MyNI

sprintf (MathScript RT Module Function)

LabVIEW 2010 Help

Edition Date: June 2010

Part Number: 371361G-01

»View Product Info

Owning Class: string

Requires: MathScript RT Module

Syntax

str = sprintf(format, a)

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

Description

Formats the input data as a string. sprintf(format, a) applies a format until LabVIEW formats all the data in a or an error occurs. If a is a 2D matrix, LabVIEW formats a in column-wise order. sprintf(format, b, ...) formats the input data based on the corresponding format specifier. If you specify b, the number of specifiers in format must match the number of data elements in b.

Examples

Inputs

Name Description
a Specifies the data you want to format as a string. a is a double-precision, floating-point number, a string, or a 1D or 2D matrix of those data types.
b Specifies the data you want to format as a string. b is a double-precision, floating-point number, or a string.
format Specifies the format you want to apply to a or b. format must use appropriate format specifier syntax. format is a string.

Outputs

Name Description
str Returns a or b as a formatted string.

Examples

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

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

Related Topics

fprintf
int_to_str
num_to_str
strread


 

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
Add Comments 1 2 3 4 5 submit