This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Display statements during function execution


echo on
echo off
echo fcnname on
echo fcnname off
echo fcnname
echo on all
echo off all


The echo command controls the display (or echoing) of statements in a function during their execution. Normally, statements in a function file are not displayed on the screen during execution. Command echoing is useful for debugging or for demonstrations, allowing the commands to be viewed as they execute.

The echo command behaves in a slightly different manner for script files and function files. For script files, the use of echo is simple; echoing can be either on or off, in which case any script used is affected.

echo on turns on the echoing of commands in all script files.

echo off turns off the echoing of commands in all script files.

echo toggles the echo state.

When you turn on echoing for a script or function file, each line in the file is displayed as it is executed. Since this results in inefficient execution, use echo only for debugging.

echo fcnname on turns on echoing of the named function file.

echo fcnname off turns off echoing of the named function file.

echo fcnname toggles the echo state of the named function file.

echo on all sets echoing on for all function files.

echo off all sets echoing off for all function files.


  • To avoid confusing syntax, do not use on or off as a function name.

See Also

Introduced before R2006a