Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Undefined function or variable - for no reason...
Replies: 1   Last Post: Feb 10, 2013 10:36 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View  
Steven Lord

Posts: 17,944
Registered: 12/7/04
Re: Undefined function or variable - for no reason...
Posted: Feb 10, 2013 10:36 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply



"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




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.