default overloading method? or a way to return subclass objects of built-in classes?
Ältere Kommentare anzeigen
I am trying to create a class that has some property, 'matrix'. If I have not explicitly defined an overloaded method for some function for my class, I would like to have it operate on this property, matrix, and then wrap it back up as an object of my class. Without a default method, I might have to use repeated try catch statements such as (for a simple with a single input and output):
try
output_argument = some_function(obj);
catch ME
if ME.identifier ... indicates the function only takes doubles
output_argument = make_obj(some_function(obj.matrix)),obj_template);
end
end
Is it possible to define a default catchall like this?
If that's not possible, is there a way to change the default behavior so that operations on subclasses of built-in classes return subclasses? (instead of "Operations on data values return objects of the superclass" as seen here http://www.mathworks.es/help/techdoc/matlab_oop/brgze9_-1.html#brr3cdl-1)
Thanks!
Antworten (1)
Daniel Shub
am 18 Jun. 2011
0 Stimmen
I think you can overload subsref to get behavior like this.
1 Kommentar
Jared
am 18 Jun. 2011
Kategorien
Mehr zu Construct and Work with Object Arrays finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!