1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
NeX [460]
3 years ago
8

In this this problem you will be using for loops to take a matrix of random number and create a new matrix that is the same as t

he random matrix, but with zeros on the diagonal. a) Create matrix m that is a 10x10 matrix of random whole numbers from 1 to 20. You will have to manipulate the random number generator function to modify the interval and get only whole numbers. b) Create a for loop that runs for index i equal to the index for every row in the matrix. Next, create a nested for loop that runs for index j equal to the index for every column in the matrix. This is very similar to the Your Turn - Extra slide of Lecture 13. c) Now, we want to use our for loops to create a new niatrix, n, that is equal to matrix m, but with zeros on the diagonal. You should use an if/else statement to create this new matrix. If the location is on the diagonal (i=j), then the value of matrix n at the location will be zero. Otherwise, the value of matrix n equals the value of matrix m at each location
Engineering
1 answer:
motikmotik3 years ago
5 0

Answer:

import numpy as np

# creating matrix of order 10*10 with random numbers between 1 and 20

m = np.random.randint(1,20, size=(10,10))

# create new matrix which reads matrix m and produces zero along the diagonal

n = np.random.randint(1,20, size=(10,10)) # create new matrix, n

for i in range(0,10): # loop through row of matrix

 for j in range(0,10): # loop through column of the matrix

   if i==j: # check for the diagonal element

     n[i][j] = 0 # asign diagonal value to zero

   else:

     n[i][j] = m[i][j] # assign the value of matrix m to n

# displaying m and n matrix in the given format using disp function

from io import StringIO

buf = StringIO()

np.disp(m,device=buf)

m = buf.getvalue()

m = m[1:-1] #removing the extra [ and ]from beginning and end

print("m = ")

print(m.replace(" [","").replace('[',"").replace(']',""))

buf = StringIO()

np.disp(n,device=buf)

n = buf.getvalue()

n = n[1:-1] #removing the extra [ and ]from beginning and end

print("n = ")

print(n.replace(" [","").replace('[',"").replace(']',""))

Explanation:

You might be interested in
In plumbing what is a video snake used for
aleksley [76]

Answer:

How to stop toilets  

Explanation:

I think

Hope this helps

7 0
3 years ago
Read 2 more answers
For the following gear train, if the blue gear is moving at 50 rpm, what are the speeds of the other gears?
Flauer [41]

Answer:

6

Explanation:

6 teddy bears

5 0
3 years ago
How to update android 4.4.2 to 5.1​
faust18 [17]

Answer:

try settings and go to updates?

Explanation:

8 0
3 years ago
The domain of discourse is the members of a chess club. The predicate B(x, y) means that person x has beaten person y at some po
satela [25.4K]

Answer:A. No one has ever beat Nancy.

Explanation:

The dormain of discourse in a simple language is the set of entities upon which our discussions are based when discussing about something.

The dormain of discourse is also known simply as universe, can also be said to be a set of entities o

upon which certain variables of interest in some formal treatment may range.

The dormain of discourse is generally attributed to Augustus De Morgan, it was also extensively used by George Boole in his Laws of Thought.

THE LOGICAL UNDERSTANDING OF THE THE QUESTION IS THAT NO ONE HAS EVER BEAT NANCY.

8 0
3 years ago
What would the Select lines need to be to send data for the fifth bit in an 8-bit system (S0 being the MSB and S2 being the LSB)
Maurinko [17]

Answer:

A. S0 = 1, S1 = 0, S2 = 0

lines need to send data for the fifth bit in an 8 bit system

5 0
3 years ago
Other questions:
  • A manufacturer makes integrated circuits that each have a resistance layer with a target thickness of 200 units. A circuit won't
    5·1 answer
  • In the contemporary approach to control systems, benefits of continuous monitoring include which one of the following? Multiple
    9·1 answer
  • How does a carburetor work?
    7·1 answer
  • What is the Principle of Entropy Increase?
    9·1 answer
  • Power is a fundamental dimension. a) True b) False
    15·1 answer
  • A Toyota Camry of mass 1650 kg turns from Chaplin Road to Route 79, thereby accelerating from 35 MPH in the city till 70 MPH on
    6·1 answer
  • Water drains at a constant rate through a saturated soil column with a diameter of 1.5 feet and a height of 3 feet. The hydrauli
    11·1 answer
  • The pressure distribution over a section of a two-dimensional wing at 4 degrees of incidence may be approximated as follows: Upp
    9·1 answer
  • In a wire, when elongation is 4 cm energy stored is E. if it is stretched by 4 cm, then what amount of elastic potential energy
    15·2 answers
  • (i) what assumptions about the relationship between the inputs and output are inherent in this specification? do scatter plots s
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!