Undefined function or variable 'xxxxx'

232 Ansichten (letzte 30 Tage)
Hye Young
Hye Young am 23 Mär. 2012
Kommentiert: Michael Hixson am 20 Okt. 2019
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 Kommentare
Edmondo
Edmondo am 5 Jul. 2012
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
Image Analyst am 5 Jul. 2012
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.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Oleg Komarov
Oleg Komarov am 23 Mär. 2012
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 Kommentar
Michael Hixson
Michael Hixson am 20 Okt. 2019
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...

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Debugging and Analysis finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by