Question: Write a code using for loops that takes a matrix of random numbers and create a new matrix that is the same as therandom matrix,

Write a code using for loops that takes a matrix of random numbers and create a new matrix that is the same as therandom matrix, but with zeros on the diagonal. a) Create a matrix A that is a 5x5 matrix of whole random numbers from1 to 50. b) Create a for loop that runs for index i representing the number of rows in the matrix. Next, create a nested for loopthat runs for index j representing the number of columns in the matrix. c) Use for loops to create a new matrix, C, that is equal to A, but with zeros on the diagonal. a) Display A and C using the disp() function.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!