'Octave error filename undefined near line 1 column 1

I tried to run a function with octave-GUI.

I first write a function in 'testFunc.rtf'(in WordPad).

function y = testFunc(x)
y = x^2 + x^3

The path to this file is 'C:\Users\username\Desktop'.

Then on octave-GUI, I wrote such code:

cd 'C:\C:\Users\username\Desktop';
testFunc(4);

The result of this was just an error below:

error: 'testFunc' undefined near line 1, column 1

How can I solve this problem?



Solution 1:[1]

Just in case someone like me finds this page, and the above suggestion still doesn't help, some advice. This is running on a Win10 machine:

The error text itself means nothing. It's very poor. It just means "oops, something went wrong and we can't tell you why".

In my case, the file existed, and had the correct name. And was in the "current directory". Using the octave command "what" showed it was there.

But try as I might, it always gave me the error above. I tried so many things I saw suggested in other search results, like making sure the function def was at the first line of the file, etc. Even tried changing DOS -> unix line endings (cr/lf to lf). Nothing.

Then it occurred to me that I was trying to run off of a "samba share" from a linux drive. Even though it had read/write/execute privileges, it just would not actually run.

Moved the file(s) to a windows drive and it started working!

Sheesh. Good luck, all.

Avner

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Avner