MATLAB Answers

Umair Altaf

element in 2D array

Asked by Umair Altaf
on 5 Feb 2013

how can find minimun element in 2D array




No products are associated with this question.

2 Answers

Answer by Walter Roberson
on 5 Feb 2013
Edited by Walter Roberson
on 5 Feb 2013
 Accepted answer

[minval, minpos] = min(YourArray(:));
[minrow,  mincol] = ind2sub(size(YourArray), minpos);

The above if you want to know the row and column as well as the value. If you just want the value then

minval = min(YourArray(:));


Answer by James Tursa
on 5 Feb 2013

Not exactly sure what you want, but here is code to find the minimum value:

x = rand(2,2);
m = min(x(:));


Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!