octave error undefined near line 1 column 1

北战南征 提交于 2020-01-16 14:37:34

问题


I try to read a matrix from a file. The code is very simple

function [mat] = read(file)

mat = load(file_points)

But when I try to run it

read('file')

mat =

scalar structure containing the fields:

mat =


   3  4  6
   3  5  1

it shows the matrix, but when I run this command...

>>mat(1,1)

error: 'points' undefined near line 1 column 1


回答1:


From 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.

According to above, variable points is a (scalar) structure. However, if you use the_matrix_you_want = points.points; you would retrieve matrix.



来源:https://stackoverflow.com/questions/55229467/octave-error-undefined-near-line-1-column-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!