Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please explain as detail as possible, im trying to understand the concept. Thanks. Homework 5- Arrays and Images Function Name: magicSquarePair Inputs 1. (double) An

image text in transcribed

Please explain as detail as possible, im trying to understand the concept. Thanks.

Homework 5- Arrays and Images Function Name: magicSquarePair Inputs 1. (double) An LxK array 2. (double) An NxM array Outputs 1. (logicaf) 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 27615 95115 43815 15 15 15 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. You15 decide to see if both arrays are magic squares using MATLAB 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 with AI-Powered 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

Students also viewed these Databases questions