I have an array as shown here. Here Bandit
is a class that I created.
bandits = [Bandit(m1),Bandit(m2),Bandit(m3)];
Now, I want to do the following. Following is Python code which immediately gives me the maxarg of the value of the mean of each of these objects.
j = np.argmax([b.mean for b in bandits])
How can I do the same in MATLAB? To give more clarity, every bandit object has an attribute mean_value
. I.e. if b1
is a bandit object, then I can get that value using dot operator (b1.mean_value
). I want to find which among b1
, b2
, b3
has maximum mean_val
and need to get the index for it. (See the python code above. If b2
has the highest mean_val
, then finally, j
will contain index 2.)