Question: 2 2-D ARRAY: MATRIX a) Verify that column sums, row sums, and main diagonal sum of a magic square matrix are equal. Define mat1 to

2 2-D ARRAY: MATRIX a) Verify that column sums, row sums, and main diagonal sum of a magic square matrix are equal. Define mat1 to be a 3 x 3 magic square matrix. Calculate the column sums mat1ColSum, row sums mat1RowSum, main diagonal sum mat1DiagSum using sum. [1 2 3] (b) Create a 3 x 3 matrix mat2 = 4 5 6 by reshaping vec1 using reshape and transpose. | 7 8 9 Then calculate matProduct1 which is the product of mat1 and mat2 using matrix multiplication, and matProduct2 using elementwise multiplication. Observe the difference between these two multiplications. (c) Stack matProduct1 and matProduct2, then assign it to mat3 of which the size is 6 x 3. Compute the sum sumAll of all elements of mat3, column minimums mat3ColMin, and row maximums mat3RowMax of mat3. Find the row indices rowIndex and column indices colIndex of entries that are no greater than 20 in mat3. (d) Add three new columns to mat3: Extract the second column of mat3 and assign it as the fourth column of mat3. Append the vector int8(rand(6, 1)) * 255) to mat3 by specifying the column index to be end + 1. Use bracket to append the vector colon(0,36,200) to mat3 as the last column. . Check the size of mat3 and store it to mat3Size
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
