Question: write a Matlab script that prompt you to enter n, the order of the square array. Add an error check, n must be a whole

write a Matlab script that
prompt you to enter n, the order of the square array. Add an error check, n must be a whole number greater than 2. prompt to enter M, the number of square arrays to be generated. Add an error check, M must be a non-zero whole number. Use a repetition structure to create M square arrays of order
Then following two lines of code can be used to create a square array X of order n: P = randperm(n^2); X = reshape(P,[n,n]);
each of the M square arrays, compute the sums of the numbers in each row, each column, and both main diagonals.: Print the number of magic square arrays generated. Print the number of semimagic square arrays generated. A semimagic square array has all its rows and columns but not both diagonals sum to the magic constant N.
same number called magic constant N=2n(n21j In this expression, n is the order of the matrix (number of rows = number of columns =n ), and the elements of the matrix are between 1 and 12 Some facts about magic square arrays - i magic square of size 33 - 88 C magic squares of size 44 - 275,305,224 magic squares of size 55 - 1.77101> (estimation) magic squares of size 66. Example: - For n=3, the unique magic square array is shown on the right. As expected, the sums of the numbers in each row, each column, and both main diagonals are equal to N=2n(n2+1)=15. - For n=4, one of the 88 magic arrays is given on the right, As expected, the sums of the numbers in each row, each column, and both main diagonals are equal to N=2n(n2+1)=34. Write a single MATLAB script file with the name
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
