How to View MATLAB Function Codes

By Joe Friedman

MATLAB is a versatile mathematical and engineering software program capable of advanced mathematical calculations and engineering simulations. Hundreds of built-in functions carry out complicated operations with minimal user input, or the user can create a new, custom function. Whether viewing or editing the code of a built-in function or a user-created one, the process is the same. By reading the code behind the built-in ones, a user can learn how MATLAB operates and gain insight on how to make his own functions.

Step 1

Open MATLAB and wait for the command line to appear. The command line begins with: >>

Step 2

Type "edit function.m" (without quotes), where "function" is the name of the function with the code you wish to view. For example, you could type "edit factorial.m" to view the code for the factorial function.

Step 3

Press "Enter" and a MATLAB editor window will pop up, showing the function's code. The code will begin with words in a green font that explain the function and may offer examples of its use. The words in black font that are below the green are the actual function code.