Programming and Data Types    

Invoking Methods on Objects

Class methods are M-file functions that take an object as one of the input arguments. The methods for a specific class must be placed in the class directory for that class (the @class_name directory). This is the first place that MATLAB looks to find a class method.

The syntax for invoking a method on an object is similar to a function call. Generally, it looks like

For example, suppose a user-defined class called polynom has a char method defined for the class. This method converts a polynom object to a character string and returns the string. This statement calls the char method on the polynom object p.

Using the class function, you can confirm that the returned value s is a character string.

You can use the methods command to produce a list of all of the methods that are defined for a class.


 Creating Objects Private Methods