找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 7007|回复: 0
收起左侧

Matlab中fread函数用法

[复制链接]
ID:105323 发表于 2016-2-23 16:11 | 显示全部楼层 |阅读模式
  “fread”以二进制形式,从文件读出数据。语法1:[a,count]=fread(fid,size,precision)
语法2:[a,count]=fread(fid,size,precision,skip)
size:   不指定    :到尾返回读。
        N        :读出N个数据,构成列向量。
        inf      : 读出fid指向的打开的文件的全部数据。
        [M,N]     :读出N个数据,构成列向量,填入M*N矩阵
   precision(精度)
precision(精度)规定了以浮点数、整型数、字符读出时位。matlab的precision(精度)的表达式与c语言、fortran语言、是一致的。不规定precision(精度),则字符默认为:ucher、则数值默认为:双精度 。
    以下precision(精度)将保证读出具有一致的体积。
MATLAB         C or Fortran          Descriphon(精度)
'char'             'char*l'                  8 位,字符型
'uchar'           'unsigned char'        8位
'schar'            'signedchar'            8位,字符型
'int8'             'integer*1'              8位,整型数
'intl6'            'integer*2'              16位,整型数.
'int32'            'integer*4'             32 位,整型数.
'int64'            'integer*8'             64 位,整型数
'uint8'            'integer*l'              8位
'uintl6'           'integer*2'             16位
'uint32'          'integer*4'             32 位
'uint64'          'integer*8'             64 位
'float32'         'real*4'                浮点数, 32 位
'float64'         'real*8'                浮点数, 32 位


以下precision(精度)将不保证读出具有一致的体积。
MATLAB         C or Fortran         Descriphon(精度)
'short'            'short'                 16 位,整型数
'int'               'int'                     32 位,整型数
'long'             'long'                   32 (64)位,整型数
'uShort'         'Unsigned short'       16位
'uint'             'Unsignedint'           32位
'ulong'          'unsigned long'        32 (64) 位   
'float'            'float'                  浮点数, 32 位
'double'         'double'               浮点数, 64 位

以下precision(精度)规定读出指定的体积n。
'bitN'        N位,整型数     1<=N<=64
'ubitN'        N位,         1<=N<=64

回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表