The advanced usage method of fread function in MATLAB and the easily ambiguous areas in the Help document

Source: Internet
Author: User

Reference: http://cn.mathworks.com/help/matlab/ref/fread.html

Note: reference to the MATLAB version number r2015a, I am using r2013b.

These usages are given in the MATLAB Help file

    • A = fread(fileID)
    • A = fread(fileID,sizeA)
    • A = fread(fileID,sizeA,precision)
    • A = fread(fileID,sizeA,precision,skip)
    • A = fread(fileID,sizeA,precision,skip,machinefmt)

1. Where precision specifies "binary number as the encoding of what format to identify", such as ' uint8 ' is a eight-bit unsigned type.

2. The last usage is to read a precision byte, skip n (specified by skip), and then read a precision byte. but note here that "skipping N bytes" Here is the default 8-bit byte of the system, not the bytes specified by precision. the15 version of the Help document is written in very detailed, because there are a large number of examples, 2013 version of the very easy to cause ambiguity. So it is time to update the new version of MATLAB, at least look at the new version of MATLAB Web Help, they will optimize the document in the ambiguous meaning of the place.

3. When you want to read a few precision bytes at a time (a block), precision can be in the form of ' n*unint8 ', and N is the number of precision bytes per block.

PS. When the beginning of a file needs to skip a number of data to read again, first use aA = fread(fileID,sizeA,precision)移动读取指针即可,后面紧跟读取有用数据的fread()。

3. Sizea rules read how many precision, is generally a positive integer, can be omitted, r2015a Help file refers to Sizea can be in the form of [A, b], that is, the variable is read directly into the matrix of column A, column-wise, the variable is written, the r2013b of the Help file is not mentioned, But it can also be used. (later I found out in the Help document that: )

4. MACHINEFMT Specifies whether the binaries are big Endian or small (Little Endian), and the parameters are ' ieee-be ' and ' Ieee-le '. The explanation of the size end is described in http://blog.csdn.net/ce123_zhouwei/article/details/6971544.

The advanced usage method of fread function in MATLAB and the easily ambiguous areas in the Help document

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.