I’ve been building a number of classes in matlab and recently discovered that certain functions don’t behave all to well with my classes. All my objects inherit from the handle superclass
For example :
-
finobj : I can’t find any of my objects, Does my base object need to be a child of the matlab Root ? How do I set this up ?
-
clear : Clearing the environment and re-instnatiating my object tree produces a warning if I’ve changed the properties of the lower objects, possibly I need a destroy method ?
I see here http://blogs.mathworks.com/videos/2008/07/07/advanced-matlab-class-system-for-oop-in-matlab-introduction/ that one is expected to overload some of the operations but surely I’m not expected to do so for each object ?
My main question is what do I have to define for my code to behave in a sensible manner ?
findobjis for handle graphics objects, not your user-defined objects. Thus, it won’t find your objects (why would you want to find them in the first place?).clearaffects variables,clear classesaffects also class definitions. Note that in earlier versions of Matlab,clear classesalso cleared all the breakpoints.Subclasses inherit everything from superclasses (including static methods). There is no need to overload anything if you don’t want to modify that particular functionality in your subclass.
If you want to have your code behave in a sensible manner, you have to design it well. How exactly you have to design it depends very much on the problem your code is supposed to solve.