How to use MATLAB to import txt files, and in accordance with their own real-world format output to

Source: Internet
Author: User

1. The data stored in the text 264stream_720_2zhen.txt is shown in 1

Figure 1 The data to be imported

2. MATLAB read the data in the command, due to the interval between the data 2 spaces, so in the fscanf format ['%x '] in parentheses added two spaces

%read data from TXT

FID= fopen(' 264stream_720_2zhen.txt ',' R ');

YUV = fscanf(fid, ['%x ' ]);

Fclose(fid);

Figure 2 Data read in MATLAB

3. Output data to text, data in 2-bit hexadecimal output, less than two bits in front of 0.

%write data to TXT

FID= fopen(' outtxt.txt ',' WB ');

fprintf(fid,'%02x\n ',YUV); % hex Format

Fclose(fid);

Figure 3 Output to text data

4. fscanf format can be referenced matlab-->help-->fscanf

How to use MATLAB to import txt files, and in accordance with their own real-world format output to

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.