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?
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.
Octave (I'm on 4.0.3) will return this error (undefined near line 1 column 1) if you have a capital letter in your path anywhere. For example, if you have a folder on Windows, with the name d:/Myfolder/octave and then you write this:
cd d:/myfolder/octave (note the small "m")
Then octave will fail.
You have to write exactly the windows path:
cd d:/Myfolder/octave
and octave will be fine
You need to also save the file as "fileName.m"
Octave doesn't recognize 'fileName.M'. It has to be a lower-case '.m' extension
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With