第 1 行第 1 列附近的八度错误未定义

octave error undefined near line 1 column 1

我尝试从文件中读取矩阵。代码很简单

function [mat] = read(file)

mat = load(file_points)

但是当我尝试 运行 时

read('file')

垫子=

包含字段的标量结构:

mat =


   3  4  6
   3  5  1

显示矩阵, 但是当我 运行 这个命令时...

>>mat(1,1)

error: 'points' undefined near line 1 column 1

来自Octave Forge about load()

If invoked with a single output argument, Octave returns data instead of inserting variables in the symbol table. If the data file contains only numbers (TAB- or space-delimited columns), a matrix of values is returned. Otherwise, load returns a structure with members corresponding to the names of the variables in the file.

根据上文,变量points是一个(标量)结构。 但是,如果您使用 the_matrix_you_want = points.points;,您将检索矩阵。