Overloading indexing operators `()` and `{}` for custom classes in MATLAB -


i able overload indexing operators () , {} class in matlab. in particular, want able define class methods like...

% ... classdef myclass < handle      % ... other class definition stuff...      function returnval = operator{}(indexrange)         %....implementation here....     end     function returnval = operator()(indexrange)         %....implementation here....     end end 

so can create objects , do...

x = myclass(); returnedvals = x(:); returnedcells = [x{:}];  % etc. 

is possible in matlab? know easy in c++ , python ( overloading operator [] , __get__ operators respectively ). mathworks site not clear on how though.

you need overload subsref , subsasgn functions within classdef. mathworks provides full example of how works. , note if wish use overloaded method within class, need call explicitly.


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -