Question: MATLAB: hey can i have help coding this problem in matlab. i post the same question before and i got wrong answer. Thanks Problem: Magic
Problem #2: Magic Square As early as 650 BC, mathematicians had been composing magic squares, a sequence of n numbers arranged in a square such that all rows, columns, and diagonals sum to the same constant. Used in China, India, and Arab countries for centuries, artist Albrecht Drer's engraving Melencolia I (year: 1514) is considered the first time a magic square appears in European art. Each row, column, and diagonal of Drer's magic square sums to 34. In addition, each quadrant, the center four squares, and the corner squares all sum to 34. An example of a "magic square" is displayed below. 16 3 2 13 5 10 11 8 9 6 7 12 4 15 14 1 Write a program to prove a series of numbers is indeed a 4 x 4 magic square. This problem is an excellent example of moving througha matrix of values similar to grid smoothing and comprehensive data validation and checks. You should be able to apply these same concepts to other problems and on the final exam. Your program should complete the following steps, in this order: (a) Ask the user to enter their proposed magic square in a single input statement (c.g., [1 234;5 6 78;9 10 11 12; 13 14 15 16]-note this example is a 4 x 4 matrix, but NOT a magic square). You may assume the user will enter whole numbers; they will not enter either decimal values or text. (d) Check for an arrangement of 4 x 4. If the matrix is not a 4 x 4, issuc a statement to the command window informing the user of the mistake and ask the user to enter another matrix. This check should be repeated until the user enters a 4 x 4 matrix. You may assume the re-entered matrix contains only positive values; you do not need to re- check the new matrix for positive values, only for matrix dimensions. (e) Check that all values are between 0 and 30. For each value found that is outside of this range, ask the user to
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
