Why do I get the error "Unrecognized function or variable"?
7.098 Ansichten (letzte 30 Tage)
MathWorks Support Team am 27 Feb. 2012
I am receiving one of the following error messages. How can I resolve this issue?
Undefined function or variable ‹Name›.
Unrecognized function or variable ‹Name›.
Undefined function or method ‹Name› for input arguments of type ‹ClassName›.
MathWorks Support Team am 22 Aug. 2023
Bearbeitet: MathWorks Support Team am 1 Jun. 2023
MATLAB does not recognize the specified string as the name of a function on the MATLAB path or as a variable. The above error messages can be caused by:
1) Trying to use a variable that has not been defined before this line of code executes.
Undefined function or variable 'y'.
% Possible corrections:
% Change line 3 to "plot(x,t)"
% or Change line 2 from "t=x.^2;" to "y=x.^2;"
2) A typographical error when typing a function or variable name. However, later versions of MATLAB try to resolve these typos with “Did you mean” suggestions. For example,
>> foo = 42;
Undefined function or variable 'fo0'.
Did you mean:
3) The wrong case for a function or variable name. Later versions of MATLAB try to resolve these typos with “Did you mean” suggestions.
4) Changing directories so that a function you used is no longer on the MATLAB path.
5) Trying to use a function for which you are not licensed or that belongs to a MathWorks toolbox that isn’t installed. In later versions of MATLAB, this is not an “Undefined function or variable” error, and MATLAB lets you know that you are either not licensed to use the function or the appropriate toolbox is not installed.
6) Trying to use a function that belongs to a third-party toolbox that isn’t installed.
7) Trying to use a function that does not yet exist in your version of MATLAB.
8) Trying to use a function that has been removed from your version of MATLAB. In later versions of MATLAB, this is not an “Undefined function or variable” error, and MATLAB lets you know the new, preferred function to use.
9) Trying to use a variable that gets cleared from the workspace because your script or function contains "clear all" or "clearvars".
10) Calling an object method without an object as the first input.
11) Using a MEX function that is compiled on a platform different from the one in use.
12) The function or script M-file's name ends with a capital ".M" extension instead of a lowercase ".m".
1) Verify that the undefined function or variable is visible (it is on the path or in the current workspace) and that it has been defined before this line of code executes. If the undefined identifier is a function, the 'which' function can help you verify that it is visible to the function where the error occurs:https://www.mathworks.com/help/matlab/ref/which.html
2) Verify that the function that you are trying to use is available in your version of MATLAB using the built-in documentation (>> doc). If you cannot find it in our documentation, the function may have been added in a later release of MATLAB, or it may be part of a third-party toolbox that is external to MathWorks.
3) If you are trying to use a function that should be available in your version of MATLAB, from a MathWorks toolbox that you have installed and licensed for, there may be a problem with your MATLAB search path. Run the following MATLAB commands to restore it:
>> restoredefaultpath % This will remove any custom paths
>> rehash toolboxcache
See our documentation for more tips:
Weitere Antworten (1)
michael am 14 Nov. 2018
Something strange is that when I try to call some function from toolbox (communication) I'm getting that it is not existing.
Even when I'm going to %MATLABROOT%\toolbox\comm\comm where the m file is existing, I still can't run it.
Please suggest what is the issue