Undefined function or variable 'xyz'
8 次查看(过去 30 天)
显示 更早的评论
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 个评论
Edmondo
2012-7-5
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' "
Image Analyst
2012-7-5
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.
回答(1 个)
Oleg Komarov
2012-3-23
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 个评论
Michael Hixson
2019-10-20
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...
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Programming Utilities 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!