How do I use max function to set the value of the highest element in a vector to 1? For example, let A be a matrix of size 3 rows and 2 columns. I want to set A(:,1) = [0.9 0.03 0.01]' to B(:,1) = [1 0 0]. Repeating the same for the second column of A. So, I should get B = [1 0 0; 0 1 0]. So, I could obtain the index of the maximum element in each column. I don't know how to assign and change the value.This is what I could do. Please help.
A =
0.9000 0.1000
0.0300 0.5800
0.0100 0.0020
>> [ans,ind] = max(A)
ans =
0.9000 0.5800
ind =
1 2