Octave error filename undefined near line x column y

Timothée HENRY picture Timothée HENRY · Oct 31, 2013 · Viewed 61.2k times · Source

I am trying to run an Octave file which is in the working directory, but I get an error. Octave does not seem to recognize that it should run the file.

unknown@unknown> dir
.                       ex1data1.txt            plotData.m
..                      ex1data2.txt            submit.m
computeCost.m           featureNormalize.m      submitWeb.m
computeCostMulti.m      gradientDescent.m       warmUpExercise.m
ex1.m                   gradientDescentMulti.m
ex1_multi.m             normalEqn.m

unknown@unknown> ex1
error: `ex1' undefined near line 21 column 1

unknown@unknown> ex1.m
error: `ex1' undefined near line 22 column 1

Can anyone advise how I can run the ex1 file?

Answer

Timothée HENRY picture Timothée HENRY · Oct 31, 2013

This fixed the problem [at least for me, on Windows]:

Entering the following command in Octave:

>addpath(pwd)

before calling the script:

>ex1

There is more info here.