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
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.
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
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...
. We have the following algorithm. Algorithm Novel(X[0..m-1, 0..m-1]) //Input: A matrix X[0..m-1, 0..m-1] of real...
. We have the following algorithm. Algorithm Novel(X[0..m-1, 0..m-1]) //Input: A matrix X[0..m-1, 0..m-1] of real numbers for i←0 to m-2 do for j←i+1 to m-1 do    if X[i,j] ≠X[j, i]        return false return true a.   What does this algorithm compute? b. What is its basic operation? c. How many times is the basic operation executed? d. What is the efficiency class of this algorithm?
I need to find the trajectory of a projectile launched at 1000 m/s at 45 degrees...
I need to find the trajectory of a projectile launched at 1000 m/s at 45 degrees to the horizontal, launched in an easterly direction from a point on the equator. I have to assume that it is a lead sphere of radius r = 5cm. Also, what is the distance of the landing point from the launch point? Including the effects of the coriolis force and the effects of linear and quadratic air resistance. What would this trajectory look like?...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT