is It possible to overload dot notation operator?

Hi all, I would like to overload the dot notation of my object. for example if I have am object 'obj", I would like that obj.fun1 will do something else than from call the "fun1" method. Is it possible? Thansks, ior

 Accepted Answer

Hi,
I think you have to overload the subsasgn function
There you see the following example:
See how MATLAB calls subsasgn for the expression:
A.field = B;
The syntax A.field = B calls A = subsasgn(A,S,B) where S.type = '.' and S.subs = 'field'.
So it can be tricky to overload it probably.
See also here:

1 Comment

Right, subsasgn() if the object appears on the left side of an assignment, subsref() otherwise.

Sign in to comment.

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Asked:

on 14 Feb 2012

Edited:

on 11 Oct 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!