" a.pull_arm();" is equivalent to "pull_arm(a);". [There could be a difference if your method accepted two inputs, but for this particular case there isn't.] From the documentation:
"MATLAB differs from languages like C++ and Java® in that there is no special hidden class object passed to all methods. You must pass an object of the class explicitly to the method. The left most argument does not need to be the class object, and the argument list can have multiple objects. MATLAB dispatches to the method defined by the class of the dominant argument."
You can name that explicit input argument self if you want.
function reward = pull_arm(self)
reward = randn() + self.m;
end
I suspect you may want pull_arm to update a property of the object self. If that's the case you need to do one of two things. The first approach would be to call the function with the object instance as both input and output:
function self = pull_arm(self)
self.m = randn() + self.m; % Assuming m is the cumulative reward
end
and invoke this method as:
myBandit = pull_arm(myBandit);
