MATLAB: Solving Matrix Index Problem

matrix index

is anyone here know how to solve matrix index problem in matlab?? For example the following problem :
You have a matrix for which each row is a person and the column represent the number of quarters, nickels, dimes, and pennies. What is the raw index of the person with the most money?
Note for those unfamiliar with American coins ; quarter = $ 0.25, dime = $ 0.10, nickel = $ 0.05, penny = $0.01
Example :
Input a = [1 0 0 0 ; 0 1 0 0] output b = 1
since the first person will have $ 0.25 and the second person will have only $0.05
Thanks you, i need the answer..

Best Answer

c=[0.25 0.1 0.05 0.01]
a = [1 0 0 0 ; 0 1 0 0]
[max_money,b]=max(sum(bsxfun(@times,c,a),2))