Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

We want to switch rows of an input nxn matrix A according to the following rul: For a column, say the kth column, we will

image text in transcribed
We want to switch rows of an input nxn matrix A according to the following rul: For a column, say the kth column, we will compare the absolute values of forms Alk.). Alk+1,K), Alk+2.). Ain.), if the form on the p-throw, that is Alp.) has the maximum absolute value. I will switch the p-throw and throw of the matrix. We will apply this procedure to the 1st column, then the 2nd column and so on For example, A (1 2 6: 4 8 -1; 2 3-51 When we use the above procedure to the 1st column, we have to switch the 1st and the 2nd rows and the matrix becomes C-148 -1; 12.6: 23 -51 Then apply the procedure to the second column and notice you only need to compare the absolute value of A12.2) and (3.2), and All.2) will not be compared Then you may find you need switch the 2nd and the 3rd rows Aller interchanging rows, matrix becomes B=[4 8 -1; 2 3-5; 1 2 61 There is no need to deal with the last column (why?) I want you to write a FUNCTION to realize such switching for ANY nXn matrix A. It should begin with function 18,P] = rearrange(A) The first output Bis the switched matrix the second output P is such a matrix whose ith row.ith column alement is one if the ith row of matrix B was originally the jth row of matrix A. The other elements of P are all zeros. Using the above example, the corresponding P matric should be P:10 10: 001: 100) Thic.metinden We want to switch rows of an input nxn matrix A according to the following rul: For a column, say the kth column, we will compare the absolute values of forms Alk.). Alk+1,K), Alk+2.). Ain.), if the form on the p-throw, that is Alp.) has the maximum absolute value. I will switch the p-throw and throw of the matrix. We will apply this procedure to the 1st column, then the 2nd column and so on For example, A (1 2 6: 4 8 -1; 2 3-51 When we use the above procedure to the 1st column, we have to switch the 1st and the 2nd rows and the matrix becomes C-148 -1; 12.6: 23 -51 Then apply the procedure to the second column and notice you only need to compare the absolute value of A12.2) and (3.2), and All.2) will not be compared Then you may find you need switch the 2nd and the 3rd rows Aller interchanging rows, matrix becomes B=[4 8 -1; 2 3-5; 1 2 61 There is no need to deal with the last column (why?) I want you to write a FUNCTION to realize such switching for ANY nXn matrix A. It should begin with function 18,P] = rearrange(A) The first output Bis the switched matrix the second output P is such a matrix whose ith row.ith column alement is one if the ith row of matrix B was originally the jth row of matrix A. The other elements of P are all zeros. Using the above example, the corresponding P matric should be P:10 10: 001: 100) Thic.metinden

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

MySQL/PHP Database Applications

Authors: Jay Greenspan, Brad Bulger

1st Edition

978-0764535376

More Books

Students also viewed these Databases questions

Question

=+ For what reasons can and do unions go on strike?

Answered: 1 week ago

Question

=+ Is secondary industrial action common and/or legal?

Answered: 1 week ago

Question

=+What sanctions are available to employers

Answered: 1 week ago