【问题标题】:textscan txt file - Matlab文本扫描 txt 文件 - Matlab
【发布时间】:2017-10-06 02:42:41
【问题描述】:

我有一个具有这种结构的 n 行文件(X Y 坐标):

100 20
101 29
102 22
102 33
X   Y

我正在尝试使用下面的脚本读取它并使用textscan 将坐标拆分为2个不同的单元格(因此我将获得一个单元格用于X 坐标,第二个用于Y 坐标)。

clear;
fileID = fopen("E:/temp.txt");
formatSpec = '%d';
C = textscan(fileID,formatSpec,'Delimiter',' ');
fclose(fileID);

由于它不起作用,我们将不胜感激。

【问题讨论】:

    标签: matlab


    【解决方案1】:

    试试

    clear;
    fileID = fopen("E:/temp.txt");
    formatSpec = '%d%d';
    C = textscan(fileID,formatSpec);
    fclose(fileID);
    
    Xcoord=C(:, 1);
    YCoord=C(:, 2);
    

    【讨论】:

    • 考虑在你的代码中添加一些 cmets/explanation
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多