# How to Use MATLAB’s Built-in Functions

*Built-in functions* are those that come with MATLAB or are part of an add-on product. You typically don’t have source code for built-in functions and must treat them simply as black boxes. So far, you have relied exclusively on built-in functions to perform tasks in MATLAB.

## Learning about built-in functions

There are many ways you can learn about built-in functions, but if you already know the name of a function, one of the simplest makes use of the help(‘*function_name*’) command, where *function_name* is the name of the function. Try it now. Type **help(‘input’)** and press Enter in the Command window.

MATLAB does provide some types of category help. For example, type **help(‘elfun’)** and press Enter to see a listing of elementary math functions at your disposal. When you type **help(‘specfun’)** and press Enter, you see a listing of specialized math functions.

Sometimes the help information provided by the help() function becomes excessively long. In this case, you can use the more() function to present the information a page at a time. Before you use the help() function, type **more(‘on’)** and press Enter to put MATLAB in paged mode. When the help information is more than a page in length, you see a

--more--

prompt at the bottom of the screen. Press the spacebar to see the next page. If you want to see only the next line, press Enter instead. When you finish reviewing help, type **more(‘off’)** and press Enter to turn off paged mode.

Although the help() function is really useful because it displays the information you need directly in the Command window, sometimes the doc() function is a better choice. When using the doc() function, you see a nicely formatted output that includes links to example code and other information. Type **doc(‘input’)** and press Enter.

This is the option you should use when you want to get an in-depth view of a function rather than simply jog your memory as part of writing an application. In addition, when you find that the help() function is less helpful than you’d like, the doc() function generally provides more information.

Using help() may not always be possible because you don’t know the precise name of whatever you need to find. Another useful function is docsearch(). You use this function when you have some idea, but not a precise one, of what you need to find.

For example, type **docsearch(‘input’)** and press Enter in the Command window. This time you see a list of potential entries to query. Notice that the input() function is still the first entry on the list, but you have a number of other choices as well.

One of the more interesting ways to search for built-in functions is to use the lookfor() function. In this case, MATLAB doesn’t look in the documentation; rather, it looks in the source code files. This kind of search is important because you can sometimes see connections between functions this way and find alternatives that might not normally occur to you.

To see how this kind of search works, type **lookfor(‘input’)** and press Enter. Notice that the input() function is in the list, but it doesn’t appear at the top because the search doesn’t sort the output by likely candidate.

If you really want to know more about the built-in functions from a coding perspective, start with the which() function, which tells you the location of the built-in function. For example, type **which(‘input’)** and press Enter. You see the location of this built-in function on your system.

At this point, you know that input() is found in the lang folder. However, you really don’t know what related functions might be in the same folder. Use the what() function to locate additional information about the content of the lang folder. To see this for yourself, type **what(‘lang’)** and press Enter.