- Scilab help
- Files : Input/Output functions
- basename
- chdir
- copyfile
- createdir
- deletefile
- dir
- dirname
- dispfiles
- fileext
- fileinfo
- fileparts
- filesep
- findfiles
- fprintf
- fprintfMat
- fscanf
- fscanfMat
- fullfile
- fullpath
- get_absolute_file_path
- getdrives
- getlongpathname
- getrelativefilename
- getshortpathname
- %io
- isdir
- isfile
- listfiles
- listvarinfile
- ls
- maxfiles
- mclearerr
- mclose
- mdelete
- meof
- merror
- mfprintf
- mscanf
- mget
- mgetl
- mgetstr
- mkdir
- mopen
- movefile
- mput
- mputl
- mputstr
- mseek
- mtell
- newest
- pathconvert
- pathsep
- pwd
- removedir
- rmdir
- 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
mget
reads byte or word in a given binary format and convert to double
mgeti
reads byte or word in a given binary format return an int type
Calling Sequence
x=mget([n,type,fd]) x=mgeti([n,type,fd])
Arguments
- n
a positive scalar: The number of items to be read.
- fd
a scalar. The
fd
parameter returned by the functionmopen
. -1 stands for last opened file. Default value is -1.- type
a string. Give the binary format used to write all the entries of x.
- x
a vector of floating point or integer type numbers
Description
The mget
function reads data in the input
specified by the stream parameter fd
and returns a
vector of floating point data. The mgeti
function reads
data in the input specified by the stream parameter fd
and returns a vector of integer data.
Data is read at the position at which the file pointer is currently pointing and advances the indicator appropriately.
The type
parameter is a conversion specifier
which may be set to any of the following flag characters (with default
value "l"):
Note, On Windows, default behavior is to skip byte 13 (0x0D). mopen should be called with the `b` option, e.g. fd1=mopen(file1,'rb') , so that all bytes will be read without exception.
Data type:
- d
double
- f
float
- l
long
- i
int
- s
short
- c
character
Optional flag:
- u..
unsigned (in combination with one of the above types)
- ..l
little endian (in combination with one of the above types)
- ..b
big endian (in combination with one of the above types)
Bytes read are automatically swapped if necessary (by checking little=endian status).
This default swapping behavior can be suprressed by adding a flag in the mopen function.
Formats "l", "d", and "f" are only valid with the mget function.
Examples
file1 = 'test1.bin'; file2 = 'test2.bin'; fd1=mopen(file1,'wb'); fd2=mopen(file2,'wb'); mput(1996,'ull',fd1); mput(1996,'ull',fd2); mclose(fd1); mclose(fd2); fd1=mopen(file1,'rb'); if 1996<>mget(1,'ull',fd1) ;write(%io(2),'Bug');end; fd2=mopen(file2,'rb'); if 1996<>mget(1,'ull',fd2) ;write(%io(2),'Bug');end; mclose(fd1); mclose(fd2);
See Also
- 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.
- mgetl — read lines from an text file
- 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
- mputl — writes strings in an ascii file
- mputstr — write a character string in a file
- mscanf
- mseek — set current position in binary file.
- mtell — binary file management
- mdelete — Delete file(s)
<< mscanf | Files : Input/Output functions | mgetl >> |