View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
The Object of My Callback

Be the first to rate this file! 4 Downloads (last 30 days) File Size: 1.35 KB File ID: #23472 Version: 1.0
image thumbnail

The Object of My Callback



29 Mar 2009 (Updated )

(object references with Matlab timers)

| Watch this File

File Information

How can I have a timer whose callback points to an object? (For example, invokes a method on a particular instance of a user-defined class - possibly, the instance that 'hosts' the timer, when the timer serves as the object's 'heartbeat').
The solution I came up with employs Singleton pattern to create and access multiple instances, identifies those by id's, and hard-codes the id's into timer callbacks. (As a shortcut, sample class Widget identifies id with an 'existing' property, Color - now, no two widgets of the same color can be created - but this is not necessary, and 'getInstance' is easy to modify). Things get more complicated when one handles deletion of singletons, which included code does not do.

Is there a simpler way?


Scrolling Display inspired this file.

This file inspired Order Book Simulation.

MATLAB release MATLAB 7.7 (R2008b)
MATLAB Search Path
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
04 Apr 2016 1.0


Contact us