Kahibaro
Discord Login Register

Finding Functions in Toolboxes

Why Finding Functions in Toolboxes Matters

When you use MATLAB toolboxes, the biggest challenge at the beginning is not running the functions, but knowing that they exist and how to find them. Toolboxes can contain hundreds or thousands of functions. Learning how to search and discover them is essential if you want to take advantage of what you have already installed instead of trying to re‑invent solutions.

In this chapter you learn how to locate functions in installed toolboxes, how to check where a function comes from, and how to explore related functionality once you find a useful command.

Using the `help` and `doc` Commands for Toolbox Functions

If you already know or suspect the name of a function, help and doc are the most direct ways to learn about it and see what toolbox it belongs to.

In the Command Window, type, for example:

matlab
help fitlm

MATLAB prints a short description of the fitlm function. Near the top of the help text you will see a line that looks similar to:

text
Statistics and Machine Learning Toolbox

This line tells you the toolbox that provides the function. If you want the full documentation page with examples, use:

matlab
doc fitlm

The documentation page usually has a header or a navigation trail indicating the toolbox and category, for instance:

text
Statistics and Machine Learning Toolbox > Regression

This confirms the function’s origin and helps you understand the context where it is used.

If help shows a message like:

text
'fitlm' not found.

you either misspelled the name, or the function belongs to a toolbox that is not installed or not available in your license.

Discovering Functions with the `lookfor` Command

Often you do not know the function name at all. In that situation, lookfor helps you search across many functions based on keywords in their help summaries.

You can start a broad search like:

matlab
lookfor regression

MATLAB scans the first line of the help for many functions and shows a list of possible matches together with brief descriptions and, in many cases, the toolbox category in square brackets, for example:

text
fitlm       - Linear regression model [Statistics and Machine Learning Toolbox]
regress     - Multiple linear regression [Statistics and Machine Learning Toolbox]
polyfit     - Polynomial fit [MATLAB]

This output serves two purposes. It suggests possible functions and reveals which ones are toolbox functions and which belong to base MATLAB.

The lookfor search can be more focused. If you want to search only exact matches in the first help line, use:

matlab
lookfor -all filter

This prints every function whose help line contains the word “filter”, including those from Signal Processing Toolbox, Image Processing Toolbox, and others. You can then follow up with help or doc on specific functions that look promising.

Keep in mind that lookfor searches through many files, so it might take some time the first time you run it in a session.

Identifying the Toolbox of a Function with `which`

When you encounter a function name, for example in someone else’s code, it is important to know where it comes from. The which command shows the file that MATLAB actually calls when you use a function name.

For instance:

matlab
which spectrogram

The output might look like:

text
C:\Program Files\MATLAB\R2024b\toolbox\signal\signal\spectrogram.m

This tells you several things. It is a MATLAB function file, with full path including toolbox\signal\signal, which implies that spectrogram belongs to Signal Processing Toolbox.

If you run which with the -all option:

matlab
which -all spectrogram

you see every function or method with that name on the path. This is useful when there are multiple functions with the same name in different toolboxes or your own folders. Typically one of them, usually the first in the list, is the toolbox version.

which itself does not print the toolbox name explicitly, but you can infer the toolbox from the folder structure or combine it with doc:

matlab
doc spectrogram

The documentation page clearly states which toolbox the function belongs to.

Browsing Toolbox Function Lists in the Documentation

Each toolbox has a section in the MATLAB documentation where its functions are organized by topic. Once you know that you want to work in a certain area, for example signal processing or optimization, browsing the toolbox reference pages is an efficient way to discover functions you did not know about.

In the Help browser, you can reach toolbox documentation in several ways:

From the Home tab, click the Help icon, then expand the product list in the documentation home page. Each installed toolbox appears in the list. When you click a toolbox name, you see an overview page with sections such as “Getting Started”, “Examples”, and “Functions”.

On the toolbox page, look for a “Functions” or “Function Reference” link. This brings you to an alphabetic or categorized list of all functions in that toolbox. For example, the Optimization Toolbox functions page groups functions into categories like “Linear Programming”, “Nonlinear Optimization”, and “Equation Solving”. Each function name links to its full documentation.

You can also navigate there directly from a function’s documentation page. At the top of a function page there is often a breadcrumb trail similar to:

text
Signal Processing Toolbox > Spectral Analysis

Click “Signal Processing Toolbox” or “Functions” in that trail to see the function list. This is a convenient way to find related commands once you are reading about one function.

Searching by Topic Using the Help Browser

If you know the general topic but not a specific function name, the search field in the Help browser is a good starting point. Type a term like “Fourier transform” or “classification” and press Enter. The results page usually groups matches by product, for example:

MATLAB
Signal Processing Toolbox
Statistics and Machine Learning Toolbox

This grouping helps you see which toolboxes contain relevant functions and documentation examples. The entries may include individual function reference pages, as well as example workflows and “How To” articles that introduce sets of functions.

When you open a result that belongs to a toolbox, the product name appears clearly on the page. From there you can follow links to the toolbox’s function list or to related topics.

In addition to the main search, many documentation pages have a “See Also” section near the bottom. This list contains links to related functions and sometimes to related toolbox features. Once you have found one relevant function, “See Also” is a quick way to expand your toolbox vocabulary around the same theme.

Using the Function Browser in the Editor

When you write code in the MATLAB Editor, you can use the built in function hints to discover functions interactively.

If you begin typing a function name, MATLAB typically shows suggestions below the cursor. For instance, typing ima might bring up:

text
imagesc    (Image Processing Toolbox)
imadjust   (Image Processing Toolbox)
imshow     (Image Processing Toolbox)

Next to the function names, MATLAB often shows the toolbox tag in parentheses. This tells you immediately that these functions belong to Image Processing Toolbox.

If you accept one of the suggestions and then hover the mouse cursor over the function name in your code, a small tooltip appears. It usually contains the first line of help text and the toolbox name. Clicking the link in the tooltip opens the full documentation page. This feature helps you explore toolbox functions without leaving the Editor.

Some versions of MATLAB also provide a “Functions” or “Function Browser” panel where you can type partial names or filter by product. This is another interactive way to search for functions while you code.

Recognizing Toolbox Functions in the Command Window

When you call a toolbox function in the Command Window, MATLAB sometimes displays short installation or licensing messages the first time. For example, if you call a function from a toolbox that is not licensed, you might see an error referring to that specific toolbox. This message reveals where the function belongs.

For installed toolboxes that are licensed, you usually use the functions without additional messages. To verify the origin of a function you just used, you can run:

matlab
help functionName
which functionName
doc functionName

in sequence. This quickly gives you the summary, the location on disk, and the full documentation including the toolbox name.

Combining MATLAB Search Tools with Web Resources

The MATLAB Help browser is tightly integrated with MathWorks online documentation. If your MATLAB installation has internet access, the search field may show web results as well, especially for newer functions or examples not stored locally.

You can also go directly to the MathWorks website and use the search field there. Typing a topic like “curve fitting” or a function name such as fitrgp shows results grouped under headings like:

Documentation
Examples
Functions

Clicking a function entry opens the online reference page, which clearly lists the toolbox and often links to a “Functions” page for that toolbox, letting you discover related commands. This is useful when you are working away from MATLAB itself but still want to explore toolboxes and their capabilities.

Understanding When a Function Requires a Toolbox You Do Not Have

When you find a helpful function, it is important to know whether you actually have access to it. Even if it appears in documentation, your license might not include the corresponding toolbox.

If you attempt to call a function that belongs to a toolbox you do not own, MATLAB usually produces an error like:

text
Undefined function or variable 'functionName'.
Or:
License checkout failed.
License Manager Error -X.

The message may refer to the specific toolbox. That tells you that the function exists in that toolbox but is not available under your license.

You can also use the ver command in the Command Window to list installed products:

matlab
ver

If a toolbox is not listed there, its functions will not be available, even if you see them in online documentation or example code. Once you know which toolbox a missing function belongs to, you can either look for an alternative in the toolboxes you do have or consider adding that toolbox.

Important points to remember:
Use help and doc on a function name to see its description and toolbox.
Use which to find the physical location of a function file and infer its toolbox.
Use lookfor when you know the task or keyword but not the function name.
Browse toolbox documentation pages to see complete function lists organized by topic.
Check errors and ver output to understand whether a toolbox function is available in your installation.

Views: 3

Comments

Please login to add a comment.

Don't have an account? Register now!