標(biāo)題: Matlab中fread函數(shù)用法 [打印本頁]

作者: 51黑黑黑    時間: 2016-2-23 16:11
標(biāo)題: Matlab中fread函數(shù)用法
  “fread”以二進(jìn)制形式,從文件讀出數(shù)據(jù)。語法1:[a,count]=fread(fid,size,precision)
語法2:[a,count]=fread(fid,size,precision,skip)
size:   不指定    :到尾返回讀。
        N        :讀出N個數(shù)據(jù),構(gòu)成列向量。
        inf      : 讀出fid指向的打開的文件的全部數(shù)據(jù)。
        [M,N]     :讀出N個數(shù)據(jù),構(gòu)成列向量,填入M*N矩陣
   precision(精度)
precision(精度)規(guī)定了以浮點(diǎn)數(shù)、整型數(shù)、字符讀出時位。matlab的precision(精度)的表達(dá)式與c語言、fortran語言、是一致的。不規(guī)定precision(精度),則字符默認(rèn)為:ucher、則數(shù)值默認(rèn)為:雙精度 。
    以下precision(精度)將保證讀出具有一致的體積。
MATLAB         C or Fortran          Descriphon(精度)
'char'             'char*l'                  8 位,字符型
'uchar'           'unsigned char'        8位
'schar'            'signedchar'            8位,字符型
'int8'             'integer*1'              8位,整型數(shù)
'intl6'            'integer*2'              16位,整型數(shù).
'int32'            'integer*4'             32 位,整型數(shù).
'int64'            'integer*8'             64 位,整型數(shù)
'uint8'            'integer*l'              8位
'uintl6'           'integer*2'             16位
'uint32'          'integer*4'             32 位
'uint64'          'integer*8'             64 位
'float32'         'real*4'                浮點(diǎn)數(shù), 32 位
'float64'         'real*8'                浮點(diǎn)數(shù), 32 位


以下precision(精度)將不保證讀出具有一致的體積。
MATLAB         C or Fortran         Descriphon(精度)
'short'            'short'                 16 位,整型數(shù)
'int'               'int'                     32 位,整型數(shù)
'long'             'long'                   32 (64)位,整型數(shù)
'uShort'         'Unsigned short'       16位
'uint'             'Unsignedint'           32位
'ulong'          'unsigned long'        32 (64) 位   
'float'            'float'                  浮點(diǎn)數(shù), 32 位
'double'         'double'               浮點(diǎn)數(shù), 64 位

以下precision(精度)規(guī)定讀出指定的體積n。
'bitN'        N位,整型數(shù)     1<=N<=64
'ubitN'        N位,         1<=N<=64






歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1