default overloading method? or a way to return subclass objects of built-in classes?
1 view (last 30 days)
Show older comments
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!
0 Comments
Answers (1)
See Also
Categories
Find more on Construct and Work with Object Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!