简体   繁体   English

matlab 中解析错误的问题 - 无法从 .txt 导入数据

[英]Problem with parse error in matlab - Can't import data from .txt

I have a question and I'd appreciate some help.我有一个问题,希望得到一些帮助。


    temp = importdata('teste.txt');
for i= 1:size(temp.texdata,1)
    for j= 1:size(temp.texdata,2)
        if i== 1 || j <= 2   %copy alphanumeric data of 1º row and columns 1 and 2
            dados{i,j} = temp.texdata{i,j};
        elseif j-2<= size(temp.data,2)  %copy numeric data for the remain cells
            dados{i,j} = temp.data(i-1,j-2);
        end
    end
end


error: matrix cannot be indexed with .错误:矩阵不能用 索引。 error: parse error error: called from C:/......../1º Semestre/IP/projeto_2.0.m at line 134 column 1错误:解析错误错误:从 C:/......../1º Semestre/IP/projeto_2.0.m 第 134 行第 1 列调用

It appears the error on top cause I wrote on my code.看来错误最重要的原因是我写在我的代码上。

My code must import data from a very big txt file that I have.我的代码必须从我拥有的一个非常大的 txt 文件中导入数据。 Do you have any suggestions on how to solve the problem您对如何解决问题有任何建议吗

When you import the data, temp is a matrix, not a struct.导入数据时, temp是一个矩阵,而不是一个结构体。

Attempting to access a field as if it where a struct results in the error you observe尝试访问一个字段,就好像它在结构中导致您观察到的错误一样

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM