- Scilab Help
- Files : Input/Output functions
- Directory
- Paths - Filenames
- copyfile
- deletefile
- dispfiles
- fileinfo
- findfiles
- fprintfMat
- fscanfMat
- getURL
- getmd5
- %io
- isfile
- listfiles
- listvarinfile
- mclearerr
- mclose
- mdelete
- meof
- merror
- mfprintf
- mfscanf
- mget
- mgetl
- mgetstr
- mopen
- movefile
- mput
- mputl
- mputstr
- mseek
- mtell
- newest
- save format
- scanf
- scanf_conversion
Please note that the recommended version of Scilab is 2025.0.0. This page might be outdated.
See the recommended documentation of this function
mfprintf
converts, formats, and writes data to a file
Syntax
mfprintf(fd, format, a1, ..., an);
Arguments
- fd
a scalar, file descriptor given by
mopen
(it's a positive integer).If
fd
equals 0 redirection in stderr.If
fd
equals 6 redirection in stdout.OBSOLETE: 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 Cprintf
format operand syntax.- str
a character string: a string to be scanned.
- a1, ..., an
the data to be converted and printed according to the format parameter.
Description
The mfprintf
function is a interface for C-coded
version of fprintf
function.
The mfprintf
function writes formatted operands
to the file specified by the file descriptor fd
. The
argument operands are formatted under control of the
format
operand.
This function may be used to output column vectors of numbers and string vectors without an explicit loop on the elements. In that case this function 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.
Examples
fd = mopen(TMPDIR+'/text.txt','wt'); mfprintf(fd,'hello %s %d.\n','world',1); mfprintf(fd,'hello %s %d.\n','scilab',2); mfprintf(fd,'This line is built with a column vector (26:28) %d.\n',[26:28].'); mfprintf(fd,'This line is built with a row vector (26:28) %d.\n',[26:28]); A = rand(3,6); mfprintf(fd,'This line is built with a matrix %.3f.\n',A); mclose(fd); if (isdef('editor') | (funptr('editor')<>0)) then editor(TMPDIR+'/text.txt') end mfprintf(0,'stderr output.\n'); mfprintf(6,'stdout output.\n');
See also
- mclose — closes an opened file
- meof — checks if end of file has been reached
- fprintfMat — writes a matrix in a file
- mfscanf — reads input from the stream pointer stream (interface to the C fscanf function)
- fscanfMat — reads a matrix from a text file
- mget — reads byte or word in a given binary format and converts to a double type
- mgetstr — reads a character string from a file
- mopen — opens a file in Scilab
- mprintf — converts, formats, and writes data to the main scilab window
- mput — writes byte or word in a given binary format
- mputstr — writes a character string in a file
- mseek — sets current position in a binary file
- mtell — Returns the offset of the current byte relative to the beginning of a file
- mdelete — deletes file(s)
- printf_conversion — mprintf, msprintf, mfprintf conversion specifications
Report an issue | ||
<< merror | Files : Input/Output functions | mfscanf >> |