⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 file.txt

📁 自适应编码 本发明的目标是生成一种方法:对数组压缩和解压缩编码
💻 TXT
📖 第 1 页 / 共 5 页
字号:
FREAD  Read binary data from file.
    [A, COUNT] = FREAD(FID,SIZE,PRECISION) reads binary data from the
    specified file and writes it into matrix A.  Optional output
    argument COUNT returns the number of elements successfully read. 
    
    FID is an integer file identifier obtained from FOPEN.
    
    The SIZE argument is optional; if not specified, the entire
    file is read and the file pointer is at the end of the file (see
    FEOF for details); if specified, valid entries are:
        N      read N elements into a column vector.
        inf    read to the end of the file.
        [M,N]  read elements to fill an M-by-N matrix, in column order.
               N can be inf, but M can't.
    
    The PRECISION argument is a string that specifies the format
    of the data to be read. It commonly contains a datatype specifier
    like 'int' or 'float' followed by an integer giving the size in
    bits.  Any of the following strings, either the MATLAB version,
    or their C or Fortran equivalent, may be used.  If not specified,
    the default is 'uchar'.
    
        MATLAB    C or Fortran     Description
        'uchar'   'unsigned char'  unsigned character,  8 bits.
        'schar'   'signed char'    signed character,  8 bits.
        'int8'    'integer*1'      integer, 8 bits.
        'int16'   'integer*2'      integer, 16 bits.
        'int32'   'integer*4'      integer, 32 bits.
        'int64'   'integer*8'      integer, 64 bits.
        'uint8'   'integer*1'      unsigned integer, 8 bits.
        'uint16'  'integer*2'      unsigned integer, 16 bits.
        'uint32'  'integer*4'      unsigned integer, 32 bits.
        'uint64'  'integer*8'      unsigned integer, 64 bits.
        'single'  'real*4'         floating point, 32 bits.
        'float32' 'real*4'         floating point, 32 bits.
        'double'  'real*8'         floating point, 64 bits.
        'float64' 'real*8'         floating point, 64 bits.
 
    For example,
 
        type fread.m
 
    displays the complete M-file containing this FREAD help entry.  To
    simulate this command one could enter instead:
 
        fid = fopen('fread.m','r');
        F = fread(fid);
        s = char(F')
 
    The FOPEN command opens the M-file on the MATLAB path with name,
    'fread.m' for reading. The FREAD command assumes the default SIZE of
    inf and the default PRECISION of 'uchar'. It reads the entire file
    converting the unsigned characters into a column vector of class
    'double' (double precision floating point).  To display the result
    as readable text the 'double' column vector is transposed to a
    row vector and converted to class 'char' (character) using the CHAR
    function.
 
    The following platform dependent formats are also supported but
    they are not guaranteed to be the same size on all platforms.
 
        MATLAB    C or Fortran     Description
        'char'    'char*1'         character,  8 bits (signed or unsigned).
        'short'   'short'          integer,  16 bits.
        'int'     'int'            integer,  32 bits.
        'long'    'long'           integer,  32 or 64 bits.
        'ushort'  'unsigned short' unsigned integer,  16 bits.
        'uint'    'unsigned int'   unsigned integer,  32 bits.
        'ulong'   'unsigned long'  unsigned integer,  32 bits or 64 bits.
        'float'   'float'          floating point, 32 bits.
 
    The following formats map to an input stream of bits rather than
    bytes.
 
        'bitN'                     signed integer, N bits  (1<=N<=64).
        'ubitN'                    unsigned integer, N bits (1<=N<=64).
 
    If the input stream is bytes and FREAD reaches the end of file
    (see FEOF) in the middle of reading the number of bytes required
    for an element, the partial result is ignored. However, if the
    input stream is bits, then the partial result is returned as the
    last value.  If an error occurs before reaching the end of file,
    only full elements read up to that point are used.
 
    By default, numeric values are returned in class 'double' arrays.
    To return numeric values stored in classes other than double,
    create your PRECISION argument by first specifying your source
    format, then following it by '=>', and finally specifying your
    destination format. You are not required to use the exact name
    of a MATLAB class type (see CLASS for details) for the destination.
    The name is translated for you to the name of the most appropriate
    MATLAB class type.  If the source and destination formats are the
    same then the following shorthand notation may be used:
 
        *source
 
    which means:
 
        source=>source
 
    For example,
 
        uint8=>uint8               read in unsigned 8-bit integers and
                                   save them in an unsigned 8-bit integer
                                   array
 
        *uint8                     shorthand version of previous example
 
        bit4=>int8                 read in signed 4-bit integers packed
                                   in bytes and save them in a signed
                                   8-bit integer array (each 4-bit
                                   integer becomes one 8-bit integer)
 
        double=>real*4             read in doubles, convert and save
                                   as a 32-bit floating point array
 
    [A, COUNT] = FREAD(FID,SIZE,PRECISION,SKIP) includes a SKIP argument
    that specifies the number of bytes to skip after each PRECISION value
    is read. If PRECISION specifies a bit source format, like 'bitN' or 
    'ubitN', the SKIP argument is interpreted as the number of bits to
    skip.
 
    When SKIP is used, the PRECISION string may contain a positive
    integer repetition factor of the form 'N*' which prepends the source
    format of the PRECISION argument, like '40*uchar'.  Note that 40*uchar
    for the PRECISION alone is equivalent to '40*uchar=>double', not 
    '40*uchar=>uchar'.  With SKIP specified, FREAD reads in, at most, a 
    repetition factor number of values (default of 1), does a skip of 
    input specified by the SKIP argument, reads in another block of values
    and does a skip of input, etc. until SIZE number of values have been 
    read.  If a SKIP argument is not specified, the repetition factor is 
    ignored.  Repetition with skip is useful for extracting data in 
    noncontiguous fields from fixed length records.
 
    For example,
 
        s = fread(fid,120,'40*uchar=>uchar',8);
 
    reads in 120 characters in blocks of 40 each separated by 8 characters.
    Note that the class type of s is 'uint8' since it is the appropriate
    class corresponding to the destination format, 'uchar'.  Also since 40
    evenly divides 120 the last block read is a full block which means
    that a final skip will be done before the command is finished.  If the
    last block read is not a full block then FREAD will not finish with a
    skip.
 
    See FOPEN on how to read Big and Little Endian files.
 
    See also FWRITE, FSEEK, FSCANF, FGETL, FGETS, LOAD, FOPEN, FEOF.

 Overloaded methods
    help serial/fread.m
    help udp/fread.m
    help instrument/fread.m

help fopen

 FOPEN  Open file.
    FID = FOPEN(FILENAME) opens the file FILENAME for read access.
    (On PC systems, fopen opens files for binary read access.)
 
    FILENAME can be a MATLABPATH relative partial pathname.  If the
    file is opened for reading and it is not found in the current
    working directory, FOPEN searches down MATLAB's search path.
 
    FID is a scalar MATLAB integer, called a file identifier. You
    use the fid as the first argument to other file input/output
    routines. If FOPEN cannot open the file, it returns -1.
 
    FID = FOPEN(FILENAME,PERMISSION) opens the file FILENAME in the
    mode specified by PERMISSION.  PERMISSION can be:
    
        'r'     read
        'w'     write (create if necessary)
        'a'     append (create if necessary)
        'r+'    read and write (do not create)
        'w+'    truncate or create for read and write
        'a+'    read and append (create if necessary)
        'W'     write without automatic flushing
        'A'     append without automatic flushing
    
    Files can be opened in binary mode (the default) or in text mode.
    In binary mode no characters get singled out for special treatment.
    In text mode on the PC, the carriage return character preceding
    a newline character is deleted on input and added before the newline
    character on output.  To open in text mode, add 't' to the
    permission string, for example 'rt' and 'wt+'.  (On Unix, text and
    binary mode are the same so this has no effect.  But on PC systems
    this is critical.)
 
    If the file is opened in update mode ('+'), an input command like
    FREAD, FSCANF, FGETS, or FGETL cannot be immediately followed by 
    an output command like FWRITE or FPRINTF without an intervening 
    FSEEK or FREWIND.  The reverse is also true.  Namely, an output 
    command like FWRITE, or FPRINTF cannot be immediately followed by 
    an input command like FREAD, FSCANF, FGETS, or FGETL without an 
    intervening FSEEK or FREWIND.
 
    Two file identifiers are automatically available and need not be
    opened.  They are FID=1 (standard output) and FID=2 (standard error).
    
    [FID, MESSAGE] = FOPEN(FILENAME,PERMISSION) returns a system 
    dependent error message if the open is not successful.
 
    [FID, MESSAGE] = FOPEN(FILENAME,PERMISSION,MACHINEFORMAT) opens the
    specified file with the specified PERMISSION and treats data read
    using FREAD or data written using FWRITE as having a format given
    by MACHINEFORMAT. MACHINEFORMAT is one of the following strings:
 
    'native'      or 'n' - local machine format - the default
    'ieee-le'     or 'l' - IEEE floating point with little-endian
                           byte ordering
    'ieee-be'     or 'b' - IEEE floating point with big-endian
                           byte ordering
    'vaxd'        or 'd' - VAX D floating point and VAX ordering
    'vaxg'        or 'g' - VAX G floating point and VAX ordering
    'cray'        or 'c' - Cray floating point with big-endian
                           byte ordering
    'ieee-le.l64' or 'a' - IEEE floating point with little-endian
                           byte ordering and 64 bit long data type
    'ieee-be.l64' or 's' - IEEE floating point with big-endian byte
                           ordering and 64 bit long data type.
    
    [FILENAME,PERMISSION,MACHINEFORMAT] = FOPEN(FID) returns the filename,
    permission, and machineformat associated with the given file
    identifier. If FID does not exist then an empty string is returned for
    each variable.
 
    FIDS = FOPEN('all') returns a row vector, the file identifiers for 
    all the files currently opened by the user (but not 1 or 2).
    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -