- Aide Scilab
- Entrées/Sorties [fichiers]
- chdir
- fullfile
- getlongpathname
- getshortpathname
- mkdir
- pwd
- rmdir
- basename
- copyfile
- createdir
- deletefile
- dir
- dirname
- dispfiles
- fileext
- fileinfo
- fileparts
- filesep
- findfiles
- fprintf
- fprintfMat
- fscanf
- fscanfMat
- fullpath
- get_absolute_file_path
- getdrives
- getrelativefilename
- %io
- isdir
- isfile
- listfiles
- listvarinfile
- ls
- maxfiles
- mclearerr
- mclose
- mdelete
- meof
- merror
- mfprintf
- mscanf
- mget
- mgetl
- mgetstr
- mopen
- movefile
- mput
- mputl
- mputstr
- mseek
- mtell
- newest
- pathconvert
- pathsep
- removedir
- save_format
- scanf
- scanf_conversion
- sscanf
Please note that the recommended version of Scilab is 2025.0.0. This page might be outdated.
See the recommended documentation of this function
fscanfMat
Reads a Matrix from a text file.
Calling Sequence
M = fscanfMat(filename[, fmt]); [M, text] = fscanfMat(filename [, fmt]);
Arguments
- filename
a character string giving the name of the file to be scanned.
- fmt
a character string giving the format. This is an optional parameter, the default value is
"%lg"
.supported format: %[width].[precision]type or %type
width
: Optional number that specifies the minimum number of characters output.precision
: Optional number that specifies the maximum number of characters printed for all or part of the output field, or the minimum number of digits printed for integer values.type
: lf, lg, d, i, e, f, g- M
Output variable. A matrix of real numbers.
- text
Output variable. A string matrix.
Description
The fscanfMat
function is used to read a scalar
matrix from a text file. The first non-numeric lines of the file are
returned in text
if requested and all the remaining
lines must have the same number of columns (column separator are assumed
to be white spaces or tab characters). The number of columns of the matrix
will follow the number of columns found in the file and the number of
lines is fetched by detecting eof in the input file. This function can be
used to read back numerical data saved with the
fprintfMat
(default separator used is a space).
Examples
fd = mopen(TMPDIR + "/Mat", "w"); mfprintf(fd, "Some text.....\n"); mfprintf(fd, "Some text again\n"); a = rand(6,6); for i = 1:6 , for j = 1:6, mfprintf(fd, "%5.2f ", a(i,j));end; mfprintf(fd, "\n"); end mclose(fd); a1 = fscanfMat(TMPDIR + "/Mat") A = ones(5,5) + 0.1; fprintfMat(TMPDIR + "/Matrix.txt", A, "%lg"); B = fscanfMat(TMPDIR + "/Matrix.txt", "%lg"); A == B C = [%nan, %inf, -%inf, 1]; fprintfMat(TMPDIR + "/MatrixNANINF.txt", C); D = fscanfMat(TMPDIR + '/MatrixNANINF.txt')
See Also
- scanf_conversion — scanf, sscanf, fscanf conversion specifications
- mclose — close an opened file
- meof — check if end of file has been reached
- mfprintf — converts, formats, and writes data to a file
- fprintfMat — Write a matrix in a file.
- mfscanf — reads input from the standard input (interface to the C scanf function)
- fscanfMat — Reads a Matrix from a text file.
- mget — reads byte or word in a given binary format and convert to double
- mgetstr — read a character string from a file
- mopen — open a file
- mprintf — converts, formats, and writes data to the main scilab window
- mput — writes byte or word in a given binary format
- mputstr — write a character string in a file
- mscanf
- mseek — set current position in binary file.
- mtell — binary file management
- mdelete — Delete file(s)
<< fscanf | Entrées/Sorties [fichiers] | fullpath >> |