为什么我不能在 GNU Octave 中加载文本文件?

Why can't I load text files in GNU Octave?

以下代码行是我的导师写的。这些在他的电脑上似乎运行良好。

但是,我无法像他在实验室那样加载文件。

load iris2.txt
iris2(:,1)=2;
load iris3.txt
iris3(:,1)=3;

ts=iris(48:53, :);

for i=1:rows(ts)
    clslnn(ts, ts(i, 2:end)+0.3)
end

我也在我的电脑上试过了,

>> load train.txt
error: load: unable to determine file format of 'train.txt'
>> load 'train.txt'
error: load: unable to determine file format of 'train.txt'
>>

那么,这可能是什么问题?

您可以通过以下方式指定 txt 文件中使用的格式:

[a,b,c,d] = textread("iris2.txt", "%f %f %f %f", \
 'delimiter', '\t', "endofline", "\n", 'headerlines', 1);
X = [a, b, c, d];
disp(X);

每列值将保存在对应的向量a,b,c,d中。 X=[a,b,c,d]; 将它们合并为一个矩阵。

我找到问题了

.txt 带字符串的文件(即使部分存在)不能以这种方式加载。