1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
mprintf Scilab Group Scilab Function mprintf
NAME
mfprintf - converts, formats, and writes data to a file mprintf -
converts, formats, and writes data to the main scilab window msprintf -
converts, formats, and writes data in a string
CALLING SEQUENCE
mfprintf(fd,format,a1,...,an);
mprintf(format,a1,...,an);
str=msprintf(format,a1,...,an);
PARAMETERS
fd : scalar, file descriptor given by mopen (it's a positive
integer). The value -1 refers to the default file ( i.e the last opened
file).
format : a Scilab string describing the format to use to write the
remaining operands. The format operand follows, as close as
possible, the C printf format operand syntax.
str : a character string, string to be scanned.
a1,...,an : Specifies the data to be converted and printed according to
the format parameter.
DESCRIPTION
The mprintf, mfprintf, and msprintf functions are interface for C-coded
version of printf, fprintf and sprintf functions.
The mprintf function writes formatted operands to the standard Scilab
output (i.e the Scilab window). The argument operands are formatted
under control of the format operand.
The mfprintf function writes formatted operands to the file specified by
the file desciptor fd. The argument operands are formatted under
control of the format operand.
The msprintf writes formatted operands in its returned value (a Scilab
string). The argument operands are formatted under control of the format
operand. Note that, in this case, the escape sequences ("\n, \t,..") are
treated as a normal sequence of characters.
All these functions may be used to output column vectors of numbers and
string vectors without an explicit loop on the elements. In that case
these functions iterates on the rows. The shortest vector gives the
number of time the format has to be iterated.
An homogeneous sequence of identical type parameters can be replaced by a
matrix
EXAMPLE
mprintf('At iteration %i, Result is:\nalpha=%f',33,0.535)
msprintf('%5.3f %5.3f',123,0.732)
msprintf('%5.3f\n%5.3f',123,0.732)
A=rand(5,2);
// vectorized forms: the format directive needs
// two operand, each column of A is used as an operand.
// and the mprintf function is applied on each row of A
mprintf('%5.3f\t%5.3f\n',A)
colors=['red';'green';'blue';'pink';'black'];
RGB=[1 0 0;0 1 0;0 0 1;1 0.75 0.75;0 0 0];
mprintf('%d\t%s\t%f\t%f\t%f\n',(1:5)',colors,RGB)
SEE ALSO
mclose, meof, mfprintf, fprintfMat, mfscanf, fscanfMat, mget, mgetstr,
mopen, mprintf, mput, mputstr, mscanf, mseek, mtell
|