Why do I receive an "Unrecognized function or variable" error when trying to use a built-in function of MATLAB or an installed toolbox?

301 views (last 30 days)
When using a built-in function of MATLAB I receive one of the following errors:
Undefined function or variable ‹function_name›.
Unrecognized function or variable ‹function_name›.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 18 Dec 2023
Edited: MathWorks Support Team on 18 Dec 2023
If you are unable to use a built-in function from MATLAB or its associated toolboxes, please make sure that the function file is installed.
If you know which toolbox the function belongs to, verify that the toolbox is installed by running this command in your MATLAB command window:
>> ver
If you do not see the toolbox and you believe that it is installed, try resetting the MATLAB path to the default. MATLAB stores the toolbox information in a cache file. You will need to first update this cache and then reset the path. To do this:
1. Go to the "HOME" tab to "Preferences".
2. Go to the "General" heading. Click the button "Update Toolbox Path Cache" and press "OK".
3. Go to the "HOME" tab to "Set Path".
4. Click on "Default", press "OK" to change, then click "Save" and finally "Close".
(If you have added any custom paths to MATLAB, you will need to restore those later)
Run "ver" again to see if the toolbox is installed. If not, you may need to reinstall this toolbox in order to use this function. See the related MATLAB Answer post:
​​
Once "ver" shows your toolbox, run the following command to see if you can find that function:
>> which -all <function_name>
Replacing "<function_name>" with the name of the function. You should be presented with the path(s) of the function file. If you get "<function_name> not found", you may need to reinstall that toolbox for the function to be active.
NOTE: If you have multiple instances of that function that are not in the $MATLABROOT\toolbox subfolders (where $MATLABROOT is the installation folder on your machine) you may have a problem running the built-in function. See the related MATLAB Answer post:
If you receive the error message "Has no license available", there is a licensing related issue preventing you from using that function. To find the error that is occurring, you can use the following command:
>> license checkout <toolbox_license_key_name>
Replacing "<toolbox_license_key_name>" with the proper key name for the toolbox that contains your function. To find the license key name, you will need to look at the "INCREMENT" lines in your license file. For information on how to find your license file see the related solution: 1-63ZIR6 - "Where are the license files for MATLAB located?"
The license key names of all the toolboxes are located after each INCREMENT tag in the license.dat file. For example:
INCREMENT MATLAB MLM 17 00-jan-0000 0 B454554BADECED4258 \
HOSTID=123456 SN=123456
If your "license.dat" file has no "INCREMENT" lines, refer to your license administrator for these "INCREMENT" lines.
For example, to test the licensing for Symbolic Math Toolbox, you can run this command:
>> license checkout Symbolic_Toolbox
A correct testing will give the result "ANS=1"; otherwise a network license manager error will be presented. You can either troubleshoot the error by looking up the license manager error here:
Please ensure that the function you are using exists in the release of MATLAB you are using. For example, if you want to use the "combinations" function, you won't be able to do so unless you are using R2023a or newer. To determine whether or not the function you are trying to use is supported in the MATLAB release you are using, please view the documentation page for the function in question.
If needed, please contact the Installation Support Team with the issue you're facing from the link below.
When contacting support, provide your license number, your MATLAB version, the function you are using, and the network license manager error (if applicable).
  1 Comment
Steven Lord
Steven Lord on 14 Dec 2023
Another reason a function listed in the online documentation may not be available is if you're using an older release of the product that contains it. To check this open the documentation page for the function in the online documentation and scroll to the end of the page. The Version History section on the page should indicate when the function was introduced.
As an example, the combinations function indicate it was "Introduced in R2023a". If you're using release R2022b or earlier of MATLAB, this function will not be available in MATLAB.

Sign in to comment.

More Answers (0)

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!