Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Sams Teach Yourself Beginning Databases In 24 Hours

Authors: Ryan Stephens, Ron Plew

1st Edition

067232492X, 978-0672324925

More Books

Students also viewed these Databases questions