return
Return control to invoking script or function
Syntax
Description
return
forces MATLAB® to return control to the invoking program before it reaches the end of
the script or function. The invoking program is a script or function that calls the
script or function containing the call to return
. If you call the
script or function that contains return
directly, there is no
invoking program and MATLAB returns control to the command prompt.
Note
Be careful when you use return
within conditional
blocks, such as if
or switch
, or
within loop control statements, such as for
or
while
. When MATLAB reaches a return
statement, it does not
just exit the loop; it exits the script or function and returns control to
the invoking program or command prompt.
Examples
Extended Capabilities
Version History
Introduced before R2006a