How can I find the (i, j)
index of the minimum element of a matrix?
For example:
M = [3 6 2; 5 5 9; 1 4 4];
I would want to get the output (3, 1)
.
How can I find the (i, j)
index of the minimum element of a matrix?
For example:
M = [3 6 2; 5 5 9; 1 4 4];
I would want to get the output (3, 1)
.
Try this:
M = [3 6 2; 5 5 9; 1 4 4];
[~, ind] = min(M(:));
[i, j] = ind2sub(size(M), ind);
[r,c]=find(M==min(M(:)))
Hope this helps...
[value,index] = min(M(:))
will give:
value = 1
index = 3