Exercise 3.2 Create a 4 x 4 matrix M4 via using the MATLAB command: M, = magic(4
ID: 2248365 • Letter: E
Question
Exercise 3.2 Create a 4 x 4 matrix M4 via using the MATLAB command: M, = magic(4) (a) Compute the row vector r and the column vector c whose elements are, respectively, defined by the sums of the columns and the rows of M4. State your observation. (b) Apply a single MATLAB statement to generate a 4 × 4 matrix M, which is characterized by the property that the sums of its columns and rows are identically reduced by 1 compared with their counterparts of M4 Caution: Entering the elements of c, r and M manually will receive NO credit.Explanation / Answer
Solution :
a)
Craete a 4x4 matrix using matlab command :
A = magic(4)
This gives :
Next check the sum along row :
similarly along column :
observation : the elements of magic matrix are created such that the sum along row and column is equal.(and in this case it is equal to 34)
b)
To create the matrix 4x4 with sum along row and column reduced by values 1 , we defined another matrix as :
in this case :
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.