MATLAB: How to define minimum value matrix

columnmatrix

Hello everyone, i have a 4×4 matrix and i can find the minimum values of each row.
A=[1,2,4,3; 4,3,7,13; 8,7,9,11; 16,14,2,7];
B=min(A, [], 2)
B =
1
3
7
2
But i need to create a matrix that gives me the columns chosen for minimum values. For example, for the A matrix this is;
C=[1,2,2,3];
I hope you understand the problem, and can help me. Thank you!!!

Best Answer

[~,idx]=min(A,[],2);