# Minimum value,row and column

200 views (last 30 days)
Giannakis Stoukas on 15 Apr 2015
Commented: Image Analyst on 11 Jun 2017
I want to find the minimum value of a matrix,the row and the column of it

Jan on 16 Apr 2015
Edited: Jan on 16 Apr 2015
[value, index] = min(A(:));
[row, col] = ind2sub(size(A), index);
In opposite to the solution of Image Analyst, this is faster, but considers only one value even if the minimal value appears multiple times in the array.
Image Analyst on 30 Apr 2016
It's the same solution I've been telling you. Now I've renamed minA to valueToFind since it appears that you're not always looking to find the min values. And since you want an (x,y) answer rather than "value of the row" like you asked for before I just concatenate them together:
A = [1 1 7 1 8; 2 4 5 9 5; 6 5 0 2 3; 3 7 5 1 9; 9 5 2 6 7]
% valueToFind = min(A(:)); % Find the min value of A
valueToFind = 5;
[row, column] = find(A == valueToFind)
MyAnswer = [column(1), row(1)] % In format [x,y] NOT [row, column]
You can call it MyAnswer, or B, or whatever you want, but I'd probably not use Answer.

Image Analyst on 15 Apr 2015
Here's one way:
minValue = min(yourArray(:));
[row, column] = find(yourArray == minValue);
Giannakis Stoukas on 15 Apr 2015
I will do it the easy way then,thanks

Kaelan Wade on 11 Jun 2017
Can't you just go
• A = some matrix
• [row,collum] = find(A == min(min(A)))
• min_val = S(row,collum)
Image Analyst on 11 Jun 2017
Yes, you can. In fact that's what my answer up above already said, though in a more efficient way. You don't need to use min twice if you use (:) and your way gives an array of all the same min value whereas most likely only a single value is needed, even if the min shows up multiple times.