Yes it is possible. Note that if you create a value object, the method must return the object in order to change the property (since value objects are passed by value). If you create a handle object ( classdef foo<handle ), the object is passed by reference.
classdef foo properties changeMe = 0; end methods function self = go(self) self.changeMe = 1; end end end
As mentioned above, a call to the method of setting the value object returns a modified object. If you want to modify the object, you need to copy the output back to the object.
f = foo; f.changeMe ans = 0 f = f.go; f.changeMe ans = 1
Jonas
source share