With the Numpy matrix.clip ()
method we can select elements from the matrix by passing the parameter as minimum value and maximum value. The output array with a range between these parameters and the size of the matrix will be the same.
Syntax:
matrix.clip()
Return: Return a matrix having value in between min and max values.
Example # 1:
In this example, we can see that using the matrix.clip ()
method we can crop the matrix between the minimum value and the maximum value.
|
Output:
[[1 2 3 4] [3 1 4 4]]
Example # 2:
|
Exit:
[[4 4 4] [4 5 6] [7 8 9]]