Answered step by step
Verified Expert Solution
Question
1 Approved Answer
MATLAB. DO NOT USE CONDITIONALS LIKE IF STATEMENTS. DO NOT USE LOOPS LIKE FOR LOOPS Function Name: magicSquarePair Inputs: 1. 2. (double) An LxK array
MATLAB.
DO NOT USE CONDITIONALS LIKE "IF" STATEMENTS.
DO NOT USE LOOPS LIKE "FOR" LOOPS
Function Name: magicSquarePair Inputs: 1. 2. (double) An LxK array (double) An NxM array Outputs: 1. (logical) A logical representing whether both arrays are magic squares Banned Functions: diag(), unique(), trace(), eye(), magic() Background: Your friend set you up on a blind date. Will there be agic between you two? Or will the evening crash and burn? Luckily for you, you realize you can use MATLAB to see if there is a connection. You and your date select nine of your favorite numbers and arrange them into arrays as shown. According to the rules passed down by the ancients, any two who both select magic squares are forever entwined in the realm of love. You decide to see if both arrays are magic squares using MATLAB 27615 95115 4 3 815 15 15 15 15 15 Function Description: Write a function in MATLAB that takes in two arrays and checks whether they are both magic squares by outputting a logical. Remember the key aspects to check for a magic square 1) The array must be square 2) All elements must be unique 3) All columns and rows add to the same number 4) Both diagonals add to the same number as the rows and columns Notes: A 1x1 matrix is a magic square Hints: Think about how you can use linear indexing to get the diagonal of the matrix without using any of the banned functions A helper function might be useful
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started