Undefined function or variable 'xyz'

Hi,friends
I have a problem with running m script.
I try to run the .m file in my current directory and Matlab would give the message - "Undefined function or variable". I add the current path and still it does not recognize any .m file in the current directory.
Moreover, any new .m file is not running at all, while some of the old .m files I executed previously are working fine.
So, I reinstalled MATLAB three times today. But still show the same problem.
Any help is most appreciated!

3 Comments

"Undefined function or variable 'xxxxxx'" is not the same as
"Undefined function or method 'xxxxx' for input
arguments of type 'double'."
I don't mean to be patronizing, have you checked that the names match exactly (case sensitively)?
I also am experiencing the same problem. Have you found any solution? In my case the function IS in the folder, but matlab says "Undefined function or variable 'main' "
Does the word "main" show up at all in your m-file? If so, paste that code here, or better yet, start your own thread.

Sign in to comment.

Answers (1)

Let's see what's the problem, unrecognised function or unrecognized variable (I admit these error messages should be rewritten):
% Make sure no variables in the workspace
clear
CASE 1 Inbuilt function, a not defined.
>> min(a)
Undefined function or variable 'a'.
CASE 2 Custom function NOT in the current directory or on any matlab path, input is defined.
>> myMin(1)
Undefined function 'myMin' for input arguments of type 'double'.
CASE 3 Custom function BUT a undefined (the input errors first)
>> myMin(a)
Undefined function or variable 'a'.
CASE 4 Case sensitive syntax, A is defined, a is NOT.
A = 1;
>> myMin(a)
Undefined function or variable 'a'.

1 Comment

My problem is case 3
myfunction=(3*T/((8/10)-3*(8/1000))-(9*(8/100)/(T^(.5))*0.8*(0.8+8/1000)))
Unrecognized function or variable 'T'.
This was working using this exact code 10 minutes ago, I saved this syntax in a text file for later use and now when I try to use it I get this error. How is that when I just had it working fine? I changed nothing...

Sign in to comment.

Categories

Find more on Programming Utilities in Help Center and File Exchange

Asked:

on 23 Mar 2012

Community Treasure Hunt

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

Start Hunting!