如何使用 matlab/Octave 在特定变量中加载文本文件?
How can I load a text file in a specific variable using matlab/Octave?
我想将 train.txt
加载到名为 train_org
的变量中。
但是,下面会产生错误?
>> train_org = load train.txt;
parse error:
syntax error
>>> train_org = load train.txt;
^
我该如何解决?
N.B。没有该变量名的文本文件可以完美加载。
您收到语法错误,因为您正在使用命令语法调用 load
函数和 you can't assign the output to a variable this way。
Command syntax does not allow you to obtain any values that might be returned by the function. Attempting to assign output from the function to a variable using command syntax generates an error. Use function syntax instead.
您需要改用标准函数语法。
train_org = load('train.txt')
我想将 train.txt
加载到名为 train_org
的变量中。
但是,下面会产生错误?
>> train_org = load train.txt;
parse error:
syntax error
>>> train_org = load train.txt;
^
我该如何解决?
N.B。没有该变量名的文本文件可以完美加载。
您收到语法错误,因为您正在使用命令语法调用 load
函数和 you can't assign the output to a variable this way。
Command syntax does not allow you to obtain any values that might be returned by the function. Attempting to assign output from the function to a variable using command syntax generates an error. Use function syntax instead.
您需要改用标准函数语法。
train_org = load('train.txt')