Question: TASK 2 OBJECTIVE: Write a function to check whether a 2-D matrix is a magic square You should work on this task individually, but you

 TASK 2 OBJECTIVE: Write a function to check whether a 2-D

TASK 2 OBJECTIVE: Write a function to check whether a 2-D matrix is a magic square You should work on this task individually, but you may discuss results with your teammates. The MATLAB function magic(N) constructs an n n magic square >> magic(3) The "magical" property of a magic square is that it contains the integers 1 to n2 exactly once each and every row, column, and diagonal has the same sum: 8+1+6-15 3+5+7-15 4+9+2-15 8+3+4-15 1+5+9-15 6+7+2-15 8+5+2-15 6+5+4-15 Now it's your turn. Write a function (verify_ magic.m) that that take as input a square matrix and computes the sum of each row, column, and diagonal of the matrix to determine whether the input is a magic square. If the input is not a square matrix, use the error function to display an error message and abort the function. The output of the function should be a logical value indicating whether or not the input is a magic square: logical true for a magic square, logical false for a muggle square Example >>verify_magic(magic(3)) >>verify magic([1 2 3;456;7 8 9]) 0

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 Databases Questions!