How to find Maximum and Minimum values in a Matrix?

How to find Maximum and Minimum values in a Matrix?

This recipe helps you find Maximum and Minimum values in a Matrix
In [1]:
## How to find Maximum and Minimum values in a Matrix
def Kickstarter_Example_13():
    print()
    print(format('How to find Maximum and Minimum values in a Matrix',
                 '*^72'))

    # Load library
    import numpy as np

    # Create matrix
    matrixA = np.array([[1, 2, 3, 23],
                       [4, 5, 6, 25],
                       [7, 8, 9, 28],
                       [10, 11, 12, 41]])

    # Return maximum element
    print(); print(np.max(matrixA))

    # Return minimum element
    print(); print(np.min(matrixA))

    # Find the maximum element in each column
    print(); print(np.max(matrixA, axis=0))

    # Find the maximum element in each row
    print(); print(np.max(matrixA, axis=1))

Kickstarter_Example_13()
***********How to find Maximum and Minimum values in a Matrix***********

41

1

[10 11 12 41]

[23 25 28 41]


Stuck at work?
Can't find the recipe you are looking for. Let us know and we will find an expert to create the recipe for you. Click here
Companies using this Recipe
1 developer from KPMG
1 developer from YASH Technologies
1 developer from Altimetrik
1 developer from LTI
1 developer from ANAC
1 developer from MudraCircle
1 developer from HvH
1 developer from Vodafone