Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.
|
|
|
|
Re: Undefined function or variable - for no reason...
Posted:
Feb 10, 2013 10:36 PM
|
|
"Ben Lange" <blange3@gmail.com> wrote in message news:kf640u$rn0$1@newscl01ah.mathworks.com... > I experienced this issue in the following scenario. > > Initially I named my .m file HW1.m, it worked fine. > I then renamed my .m file to be HW1-NearestNeighboar.m. > > I experienced the dreaded Undefined function or variable error. > > I then changed the - to _ and everything worked fine. > > Apparenly, MatLab doesn't support - characters in the *.m filename.
That is correct.
http://www.mathworks.com/help/matlab/matlab_prog/create-functions-in-files.html
"Valid function names follow the same rules as variable names. They must start with a letter, and can contain letters, digits, or underscores."
If function names were allowed to contain a minus sign, this:
HW1-NearestNeighboar(1)
would be ambiguous -- it could be either a call to the function you wrote or the result of subtracting the first element of the array NearestNeighboar from the variable HW1.
-- Steve Lord slord@mathworks.com To contact Technical Support use the Contact Us link on http://www.mathworks.com
|
|
|
|