Open In App

Numpy matrix.min() - Python

Last Updated : 20 Sep, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

The matrix.min() method find the minimum value in a matrix.

Syntax

matrix.min()

Return: Returns the minimum value from the matrix.

Examples

Example 1: In this example, we create a 2×2 matrix and use matrix.min() to get the smallest value.

Python
import numpy as np
m = np.matrix('[64, 1; 12, 3]')
mn = m.min()
print(mn)

Output
1

Explanation:

  • np.matrix('[64, 1; 12, 3]') creates a 2×2 matrix
  • m.min() scans all elements and finds the minimum value.

Example 2: Here, we create a 3×3 matrix and use matrix.min() to find the smallest number.

Python
import numpy as np
m = np.matrix('[1, 2, 3; 4, 5, 6; 7, 8, -9]')
mn = m.min()
print(mn)

Output
-9

Explanation:

  • np.matrix('[1, 2, 3; 4, 5, 6; 7, 8, -9]') creates the matrix
  • m.min() iterates over all elements and identifies the smallest number.

Explore