import numpy n = 3 A = numpy.random.randint(low=1, high=10, size=(n, n)) B = numpy.random.randint(low=1, high=10, size=(n, 1)) C = numpy.concatenate((A, B), axis=1) print("A: \n", A) print("B: \n", B) print("The Augmented Matrix C: \n", C)
Here, we are first creating two matrices A and B that contain random integers. We are using the numpy.random.randint() function for that purpose. The generated random integers will be within the range [low, high). The size argument specifies the size of the created matrix. For example, size=(n, 1) specifies that the created matrix will have n rows and 1 column. So, A is a 3×3 matrix and B is a 3×1 matrix.
Now, we are using the numpy.concatenate() function to create the augmented matrix. The two matrices should be joined along the columns. So, the argument axis is equal to 1 here.
The output of the mentioned program will be:
A: [[3 1 2] [4 5 4] [6 4 4]] B: [[6] [9] [7]] The Augmented Matrix C: [[3 1 2 6] [4 5 4 9] [6 4 4 7]]






0 Comments