stg = sprintf(formatSpec,B1,...,Bn) use to formats the data in an array with the help of formatting operators which is specified by formatSpec in MATLAB and returns the resulting text in a define variable(stg) then stg known as output and otherwise stg is an character.
MATLAB Program for Literal Text and Array Inputs
formatSpec = 'The array is %dx%d.';
A1 = 2;
A2 = 3;
str = sprintf(formatSpec,A1,A2)
Program example for MATLAB |
compose function is used to return the number of pieces of formatted text as a string array and that can be used with the MATLAB sprintf() Function.
str = sprintf(literalText) In MATLAB use to translates escape-character sequences of the literalText which is define with sprintf function in MATLAB for example :- \n and \t and sprint function return the all other characters unaltered.
Now if the string contain any formatting operator (example %f) then sprint function in MATLAB discards it and all characters after that operator.
Input Arguments for sprintf function in MATLAB
- The Output is format with the help of formatSpec and this also include the ordinary text and special characters.
- if formatSpec is include the escape characters in string then sprintf Function translates that escape characters (such as /n).
Formatting Operator of sprintf
A formatting operator for sprintf starts with a percent sign, %, and ends with a conversion character and the conversion character is also required.
You can also specified some identifier like subtype operators, field width, precision, and flags between % and conversion character which is an end point.
Read more : - fmincon Matlab Function
List Of Conversion Character for Sprintf function in MATLAB
There some of the Conversion Character
Conversion Character for Sprintf function |
Some tips : -
The sprintf function in MATLAB is similar to fprintf function but the fprintf function is used for the Command Window.
0 comments:
Post a Comment