MATLAB Object-Oriented Programming

(Joyce) #1

Techniques for Using Events and Listeners


In this section...
“Example Overview” on page 11-50
“Techniques Demonstrated in This Example” on page 11-51
“Summary of fcneval Class” on page 11-51
“Summary of fcnview Class” on page 11-52
“Methods Inherited from Handle Class” on page 11-54
“Using the fcneval and fcnview Classes” on page 11-54
“Implement UpdateGraph Event and Listener” on page 11-56
“The PostSet Event Listener” on page 11-60
“Enable and Disable Listeners” on page 11-63
“@fcneval/fcneval.m Class Code” on page 11-64
“@fcnview/fcnview.m Class Code” on page 11-65

Example Overview


This example defines two classes:


  • fcneval — The function evaluator class contains a MATLAB expression and evaluates
    this expression over a specified range

  • fcnview — The function viewer class contains a fcneval object and displays surface
    graphs of the evaluated expression using the data contained in fcneval.


This class defines two events:


  • A class-defined event that occurs when a new value is specified for the MATLAB
    function

  • A property event that occurs when the property containing the limits is changed


The following diagram shows the relationship between the two objects. The fcnview
object contains a fcneval object and creates graphs from the data it contains. fcnview
creates listeners to change the graphs if any of the data in the fcneval object change.

11 Events — Sending and Responding to Messages

Free download pdf