Question

In: Computer Science

In python find matrix M I have the matrix X X=[5.8 3.0 3.7 1.9] and need...

In python find matrix M

I have the matrix X

X=[5.8   3.0    3.7    1.9]

and need to create a matrix M that is 4x150 that has the the values of matrix X inside it for every row

M=

5.8 3.0 3.7 1.9
5.8 3.0 3.7 1.9
5.8 3.0 3.7 1.9
5.8 3.0 3.7 1.9
5.8 3.0 3.7 ect
5.8 ect ect
5.8
ect
5.8

Solutions

Expert Solution

The given matrix is:

X=[5.8   3.0    3.7    1.9]

We need to create one more matrix that has 150 rows and 4 columns and then will initialize the value from the matrix X to the newly created matrix.

The required program source code is given below:

import numpy as np

#create an array
X = np.array([5.8, 3.0, 3.7, 1.9])

#create a matrix
M = np.zeros((150, 4))

#initialize the matrix
for i in range(150):
for j in range(4):
M[i][j] = X[j]

#display the matrix
for i in range(150):
for j in range(4):
print(M[i][j],end=" ")
print()

The screenshot of the above source code is given below:

OUTPUT:

5.8     3.0     3.7     1.9                                                     

5.8     3.0     3.7     1.9                                                     

5.8     3.0     3.7     1.9                                                     

5.8     3.0     3.7     1.9                                                     

5.8     3.0     3.7     1.9

continue up to 150 rows...


Related Solutions

I need to add this checkpoint to an existing code that i have in python Checkpoint...
I need to add this checkpoint to an existing code that i have in python Checkpoint 1: Once you have created and tested the Bank Account Class create subclasses to the BankAccount class. There should be two subclasses, CheckingAccount and SavingsAccount. You should add interest_rate to the parent BankAccount class. To the CheckingAccount add variables called per_check_fee default to false and allow_overdraft default to True. To SavingsAccount add the variable transactions_per_month, default it to 5. Create instances of CheckingAccount and...
True/False: If A is an invertible m x m matrix and B is an m x...
True/False: If A is an invertible m x m matrix and B is an m x n matrix, then AB and B have the same null space. (Hint: AB and B have the same null space means that ABX = 0 if and only if BX = 0, where X is in Rn.)
Find the special fundamental matrix for the following system such that Φ(0) = I. x' =...
Find the special fundamental matrix for the following system such that Φ(0) = I. x' = row 1 ( 4 3 ) row 2 ( 3 -4 ) * x
Let A be an m x n matrix and b and x be vectors such that...
Let A be an m x n matrix and b and x be vectors such that Ab=x. a) What vector space is x in? b) What vector space is b in? c) Show that x is a linear combination of the columns of A. d) Let x' be a linear combination of the columns of A. Show that there is a vector b' so that Ab' = x'.
I need a detailed SPACE Matrix, IE Matrix, BCG Matrix QSPM for Micheal Kors company
I need a detailed SPACE Matrix, IE Matrix, BCG Matrix QSPM for Micheal Kors company
I need a SWOT Bivoriate strategy Matrix for Chipotle
I need a SWOT Bivoriate strategy Matrix for Chipotle
Consider the matrix P = I - X(XTX)-1X T . If matrix X has 4 rows...
Consider the matrix P = I - X(XTX)-1X T . If matrix X has 4 rows and 6 columns, what are the dimensions of matrix I? Prove that P is idempotent.
I have a M&A case presentation and I need to know how to answer these questions...
I have a M&A case presentation and I need to know how to answer these questions (I’ve done all the calculations already but really new to the subject and don’t know how to transform the numbers into verbal economic analysis): - What is the value of operational and financial synergies of the merger? Are they meaningful? Do you see risks in attaining them? Highlight the main pros and cons for the whole deal for company A shareholders. - What is...
Using Python: Normalize a 5x5 random matrix hints: use numpy create a random matrix X apply...
Using Python: Normalize a 5x5 random matrix hints: use numpy create a random matrix X apply Normalization: (X - Mean) / Deviation
package applications; public class Matrix { private int[][] m; public Matrix(int x, int y) { m...
package applications; public class Matrix { private int[][] m; public Matrix(int x, int y) { m = new int[x][y]; } public Matrix(int x, int y, int z) { m = new int[x][y]; for(int i = 0; i < x; i++) { for(int j = 0; j < y; j++) { m[i][j] = z; } } } public int rowsum(int i) throws IndexOutOfBoundsException { if (i < 0 || i > m.length-1) { throw new IndexOutOfBoundsException("Invalid Row"); } int sum =...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT