??? Undefined function or variable ' '.

Basic question about MATLAB programming
Post Reply
matlab1
Site Admin
Posts: 4797
Joined: Thu Dec 15, 2016 9:30 am
Contact:

??? Undefined function or variable ' '.

Post by matlab1 »

this error
matlab1
Site Admin
Posts: 4797
Joined: Thu Dec 15, 2016 9:30 am
Contact:

Re: ??? Undefined function or variable ' '.

Post by matlab1 »

MATLAB does not recognize the specified string as the name of a function on the MATLAB path or as a variable. "Undefined function or variable" can be caused by:
1) A typographical error when typing a function or variable name (such as typing a 1 [one] when you intended to type an l [low-case L]). However, later versions of MATLAB try to resolve these typos with “Did you mean” suggestions. For example,
foo = 42;
fo0
Undefined function or variable 'fo0'.
Did you mean:
>> foo
2) The wrong case for a function or variable name. Later versions of MATLAB try to resolve these typos with “Did you mean” suggestions.
3) Changing directories so that a function you used is no longer on the MATLAB path.
4) Trying to use a function for which you are not licensed or that belongs to a 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.
5) Calling an object method without an object as the first input.
6) Using a MEX function that is compiled on a platform different from the one in use.
Solution:
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 you are certain the variable or function exists, verify the case of the function or variable name. 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.
If you are having problems with your MATLAB search path, run the following MATLAB commands and then restart MATLAB.
restoredefaultpath % This will remove any custom paths
rehash toolboxcache
savepath
Example demonstrating this error:
UndefinedFunctionOrVariable.m (attached)
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests