default overloading method? or a way to return subclass objects of built-in classes?
Mostrar comentarios más antiguos
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!
Respuestas (1)
Daniel Shub
el 18 de Jun. de 2011
0 votos
I think you can overload subsref to get behavior like this.
1 comentario
Jared
el 18 de Jun. de 2011
Categorías
Más información sobre Construct and Work with Object Arrays en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!