zoukankan      html  css  js  c++  java
  • 如何利用matlab来导入txt文件,并按照自己的现实格式输出来

    1. 文本264stream_720_2zhen.txt中存储的数据如图1所示

     

                                                    图 1 要导入的数据截图

    2. MATLAB中读入数据的命令,由于数据之间间隔2个空格,所以fscanf格式中[‘%x’  ]中括号中加入了两个空格

    %read data from txt

    fid= fopen('264stream_720_2zhen.txt','r');

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

    fclose(fid);

     

     

     

     

     

     

     

     

     

     

     

    图 2 matlab中读入的数据

    3.输出数据到文本,数据以2位十六进制输出,不足两位在前面补0。

    %write data to txt

    fid= fopen('outtxt.txt','wb');

        fprintf(fid,'%02X ',YUV);     % hex format

    fclose(fid);

     

    图 3 输出到文本的数据

    4. fscanf格式可参考matlab-->help-->fscanf



     成功不一定需要努力,但封神的道路一定得写好每一行代码! 


  • 相关阅读:
    Ubuntu16.04.1 安装Nginx
    Ubuntu16.04.1 安装Redis-Cluster
    SeekBar的简单使用
    Async异步处理
    SQLite
    Shareprefrence
    android中的主线程
    Fragment的简单使用
    ArrayAdapter的使用
    用Intent传递对数
  • 原文地址:https://www.cnblogs.com/Bnian/p/5171273.html
Copyright © 2011-2022 走看看