简体   繁体   中英

octave error undefined near line 1 column 1

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM