Recipe: How to MULTIPLY numerical value to each element of a matrix?
DATA MUNGING PYTHON MATRIX

How to MULTIPLY numerical value to each element of a matrix?

This recipe helps you MULTIPLY numerical value to each element of a matrix
In [1]:
## How to MULTIPLY numerical value to each electment of a matrix
def Kickstarter_Example_17():
    print()
    print(format('How to multiply something to each electment of a matrix',
                 '*^72'))

    # Load library
    import numpy as np

    # Create two vectors
    matrixA = np.array([[2, 3, 23],
                       [5, 6, 25],
                       [8, 9, 28]])

    # Create a function that multipies 100 to something
    multiply_100 = lambda i: i * 100

    # Create a vectorized function
    vectorized_multiply_100 = np.vectorize(multiply_100)

    # Apply function to all elements in matrix
    print(); print(vectorized_multiply_100(matrixA))

Kickstarter_Example_17()
********How to multiply something to each electment of a matrix*********

[[ 200  300 2300]
 [ 500  600 2500]
 [ 800  900 2800]]


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