Main Content

Function Creation

Create functions, including anonymous, local, and nested functions

Functions contain one or more sequential commands and can accept inputs and return outputs. To write a program with multiple lines of code, create a named function in a file.

Alternatively, if you want to define a one-line function to pass to another function—for instance, a mathematical expression to pass to the integral function—you can create an anonymous function.

MATLAB Language Syntax

functionDeclare function name, inputs, and outputs