What are the differences between these two calling sequences get(a) and a.get()?
load gong
a = audioplayer(y, Fs);
a.get
get(a)
What are the differences between these two calling sequences get(a) and a.get()?
load gong
a = audioplayer(y, Fs);
a.get
get(a)
Copyright © 2021 Jogjafile Inc.
There is no difference by default. However, the behavior can be modified.
By default, for an object of a custom class,
obj.method(arg1,arg2,...)is syntactic sugar formethod(obj,arg1,arg2,...). This means that when you write the former, MATLAB pretends you wrote the latter and proceeds accordingly.However, it is possible to overload the method
subsreffor the class, in which case this function will be called for the syntaxobj.method(arg1,arg2,...). That is, MATLAB interprets it as an indexing operation (.method) followed by another indexing operation ((arg1,arg2,...)). Thesubsrefmethod is called to evaluate these indexing operations. It is possible to implement it such that the appropriate method is called in this case, but custom indexing code is executed for other indexing operations such asobj(x)orobj{x}. See for example here.