Recipe: How to add and subtract between matrices?
DATA MUNGING DATA CLEANING PYTHON

How to add and subtract between matrices?

This recipe helps you add and subtract between matrices
In [1]:
## How to add and subtract between matrices
def Kickstarter_Example_19():
    print()
    print(format('How to add and subtract between matrices', '*^72'))

    # Load library
    import numpy as np

    # Create two vectors
    matrixA = np.array([[2, 3, 23],
                       [5, 6, 25],
                       [8, 9, 28]])
    matrixB = np.array([[1, 2, 3],
                       [4, 5, 6],
                       [7, 8, 9]])
    # Add two matrices
    print(); print(np.add(matrixA, matrixB))

    # Subtract two matrices
    print(); print(np.subtract(matrixA, matrixB))

Kickstarter_Example_19()
****************How to add and subtract between matrices****************

[[ 3  5 26]
 [ 9 11 31]
 [15 17 37]]

[[ 1  1 20]
 [ 1  1 19]
 [ 1  1 19]]


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 Infosys
1 developer from Touch Idea
1 developer from Altimetrik
1 developer from KPMG
1 developer from Vodafone
1 developer from ANAC
1 developer from LTI
1 developer from YASH Technologies
1 developer from HvH
1 developer from MudraCircle