MATLAB Object-Oriented Programming

(Joyce) #1

Methods Inherited from Handle Class


Both the fcneval and fcnview classes inherit methods from the handle class. The
following table lists only those inherited methods used in this example.

“Handle Class Methods” on page 7-13 provides a complete list of methods that are
inherited when you subclass the handle class.

Methods
Inherited from
Handle Class

Purpose

addlistener Register a listener for a specific event and attach listener to event-
defining object.
notify Trigger an event and notify all registered listeners.

Using the fcneval and fcnview Classes


This section explains how to use the classes.


  • Create an instance of the fcneval class to contain the MATLAB expression of a
    function of two variables and the range over which you want to evaluate this function

  • Use the fcnview class static function createViews to visualize the function

  • Change the MATLAB expression or the limits contained by the fcneval object and all
    the fcnview objects respond to the events generated.


You create a fcneval object by calling its constructor with two arguments—an
anonymous function and a two-element, monotonically increasing vector. For example:

feobject = fcneval(@(x,y) x.*exp(-x.^2-y.^2),[-2 2]);

Use the createViews static method to create the graphs of the function. Use the class
name to call a static function:

fcnview.createViews(feobject);

The createView method generates four views of the function contained in the fcneval
object.

11 Events — Sending and Responding to Messages

Free download pdf