【发布时间】:2014-05-31 00:49:21
【问题描述】:
如果可能,请告诉我如何在 Matlab 中读取不同的文本文件。 考虑到每个人都应该处理 33 个 txt 文件。 这是我的代码有错误。 :(
textFilename = cell(1,33);
id = cell(1,33);
for k=1:33;
textFilename{k} = fullfile('C:\Users\Desktop\SentimentCode\textfiles',['file' num2str(k) '.txt']);
id{k} = fopen(textFilename{k},'rt');
str{k} = textscan(id{k},'%s%s');
end
str(str == '.') = '';
str(str == '_') = '';
str(str == '-') = '';
% Remove numbers from text
T =regexprep(str, '[\d]', ' ');
and my error is : ??? Undefined function or method 'eq' for input arguments of type 'cell'.
Error in ==> Untitled9 at 23
str(str == '.') = '';
【问题讨论】:
-
你得到什么错误?
-
非常感谢您的回复.. 我编辑了我的帖子并添加了更多内容和错误感谢您的回答
-
我在代码末尾使用了 fclose(id{k}) 。
-
并且错误的解释也是:指示的变量或数组的大小似乎随着每次循环迭代而变化。
标签: matlab list file-io text-files textscan