compose
Format data into multiple strings
Description
formats data values from the input array str = compose(formatSpec,A)A using the formatting
operators in formatSpec and returns the resulting text in
str as a string array or cell array of character
vectors.
The output
strhas the same number of rows asA.composeappliesformatSpecto each row ofA, formatting values fromAin column order using the formatting operators.If the number of columns in
Ais less than the number of formatting operators, the extra formatting operators without corresponding values inAappear unchanged instr.If the number of columns in
Aexceeds the number of formatting operators, thencomposeappliesformatSpecmultiple times to each row ofA. Any extra formatting operators from a repeated application offormatSpecappear unchanged instr.If
Ahas zero columns, thencomposereturnsstrwith the same size asAand does not apply any formatting operators.
compose also translates all escape-character sequences in
formatSpec except for \\ and
%%. Escape-character sequences represent nonprinting
characters or specify actions such as newlines or tabs.
formats data values from multiple input arrays and concatenates all the formatted
values. When str = compose(formatSpec,A1,...,AN)compose uses formatting operators from
formatSpec to convert data from an input array, then those
formatting operators become unavailable to the following input arrays.
For example, if formatSpec is "%f %f %d %s"
and A1 has two columns, then the operators "%f
%f" are applied to the values in A1 only. They
cannot be applied to A2 or any other input array.
compose applies the remaining operators, "%d
%s", to A2,...,AN.
If the number of columns in the last input array, AN, exceeds
the number of remaining operators, then compose adds an
additional column to str, as described in the previous syntax. If
the number of columns in AN is less than the number of remaining
operators, then compose puts the last unchanged operators in
str.
translates escape-character sequences in str = compose(txt)txt.
If
txtdoes not contain formatting operators, thencomposetranslates all escape-character sequences. It leaves all other characters unchanged.If
txtcontains formatting operators, thencomposetranslates all escape-character sequences except for\\and%%. It leaves all other characters, including the formatting operators, unchanged.
Examples
Input Arguments
Output Arguments
Extended Capabilities
Version History
Introduced in R2016b