function error- undefined variable

when i attempt to use a function an error occurs saying 'undefined function or variable' or it says there is an error in the script but there are none according to the side bar. its happening to every function i have - even the ones that were working previously.. HELP?!?

 Accepted Answer

Walter Roberson
Walter Roberson on 11 Jun 2011
Please copy and paste the error here.
It could be that you accidentally added your own routine with the same name as one of the built-in routines.

5 Comments

do you have any idea how to fix this?
thanks
You need to copy the exact error here so we can figure out which routine is involved. After that, you would use the "which" command on that function to determine where you accidentally wrote the file that is overriding the MATLAB version.
it was saying undefined function or variable but now its:
??? Input argument "a" is undefined.
Error in ==> get_positives at 23
for element = a
but this function was working before...
i was reading the help document stuff and it said if the undefined error came up to change 'set path' to default. ive done that but still no luck.
What statement in your code defines "a" ?
It is possible that you have a function instead of a script, and that you need to invoke the function from the command line, passing in the appropriate arguments. Look at the first non-comment line of get_positives.m and see if it starts with "function": if it does then at the command line you need to type something like
get_positives([-5,3,8,pi,-2,inf])
all is good thanks for your help.

Sign in to comment.

More Answers (0)

Categories

Find more on Environment and Settings in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!