[TOC]

min

Smallest elements

Usage

Note

M = min(A)

[M, I] = min(A)

M = min(A, [ ], k)

[M, I] = min(A, [ ], k)

min(A, B)

💡 When comparing two numbers by min, if one of them is NaN, the other number is returned. If both are NaN, it returns NaN.

Examples

Input
a = randi(10,3,3,3)

% Finding minimum values along the 3rd dimension, stored in M.
[M, I] = min(a,[],3)
Output
a(:, :, 1) = 
 9.0000   3.0000   1.0000
 3.0000   9.0000   1.0000
 10.000   2.0000   8.0000

a(:, :, 2) = 
 2.0000   7.0000   3.0000
 1.0000   4.0000   8.0000
 7.0000   1.0000   7.0000

a(:, :, 3) = 
 10.000   4.0000   6.0000
 5.0000   2.0000   4.0000
 10.000   3.0000   6.0000

M = 
 2.0000   3.0000   1.0000
 1.0000   2.0000   1.0000
 7.0000   1.0000   6.0000

I = 
 2.0000   1.0000   1.0000
 2.0000   3.0000   1.0000
 2.0000   2.0000   3.0000
Input
a = randi(10,3,3)
b = randi(10,3,3)
min(a,b)
Output
a = 
 9.0000   4.0000   1.0000
 3.0000   6.0000   3.0000
 3.0000   5.0000   2.0000

b = 
 3.0000   3.0000   5.0000
 2.0000   2.0000   10.000
 5.0000   10.000   8.0000

ans = 
 3.0000   3.0000   1.0000
 2.0000   2.0000   3.0000
 3.0000   5.0000   2.0000