|MATLAB Function Reference|
Overloaded method to display an object
prints the value of a variable or expression,
X. MATLAB calls
display(X) when it interprets a variable or expression,
X, that is not terminated by a semicolon. For example,
sin(A); does not.
X is an instance of a MATLAB class, then MATLAB calls the
display method of that class, if such a method exists. If the class has no
display method or if
X is not an instance of a MATLAB class, then the MATLAB builtin
display function is called.
A typical implementation of
disp to do most of the work and looks like this.
magic(3), with no terminating semicolon, calls this function as
As an example of a class
display method, the function below implements the
display method for objects of the MATLAB class,
polynom object. Since the statement is not terminated with a semicolon, the MATLAB interpreter calls
display(p), resulting in the output
sprintf, special characters