Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

**Write a MATLAB function S-sudoku (A) which accepts a matrix A as an input. If the matrix is not square, the function breaks and returns

image text in transcribed

**Write a MATLAB function S-sudoku (A) which accepts a matrix A as an input. If the matrix is not square, the function breaks and returns an error message ERROR using sudoku: the matrix is not square' and also returns S-sym ('undefined' Otherwise, if the matrix is square, the function computes two vectors: S1 and S2, where S1 is a row vector of the sums of entries down each column and S2 is a column vector of the sums across each row. These vectors have to be output as well (do not put semicolon at the end of the commands that compute vectors). If all sums are equal, that is, every entry of S1 and S2 is the same number, you should denote that number S and it will be an output. If the sums are different, the program outputs s-sym('undefined') and an error message: ERROR using sudoku: the sums are different'. Note: for the purpose of this program we state that two numbers are equal if the absolute value of their difference is less than 10. You should consider it in your conditional "if" statement when you check whether the sums are the same or different. The function could use a single while loop and a MATLAB built-in function sum. (Hint: the command return forces the program to terminate.) **Type the function sudoku in your diary file **Run the function s=sudoku (A) on each of the matrices below: (a) A=magic(5) (b) A-diag(diag(magic(6))) (c) A-ones(4,5) (d) A randi(10,3,3) (e) B-randi10,4,4) C-inv(B), A-B*C

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

Beginning C# 5.0 Databases

Authors: Vidya Vrat Agarwal

2nd Edition

1430242604, 978-1430242604

More Books

Students also viewed these Databases questions