Cody

# Problem 42752. Matrix diagonalization

Solution 1990246

Submitted on 25 Oct 2019 by Nikolaos Nikolaou
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
A=magic(3); B=[15.000000000000004 0 0 0 4.898979485566359 0 0 0 -4.898979485566358] y_correct=1; assert(isequal(Check_Diag(A,B),y_correct))

B = 15.0000 0 0 0 4.8990 0 0 0 -4.8990 y = logical 1 ans = 15.0000 4.8990 -4.8990 ans = 15.0000 4.8990 -4.8990

2   Pass
A=eye(5); B=eye(5); y_correct=1; assert(isequal(Check_Diag(A,B),y_correct))

y = logical 1 ans = 1 1 1 1 1 ans = 1 1 1 1 1

3   Pass
A=spiral(2) B=[3 4 4 9]; y_correct=0; assert(isequal(Check_Diag(A,B),y_correct))

A = 1 2 4 3 y = logical 0 ans = -1 5 ans = 3 9

4   Pass
A=pascal(3) B=[ 1.127016653792583 0 0 0 2.000000000000000 0 0 0 8.872983346207416] y_correct=0; assert(isequal(Check_Diag(A,B),y_correct))

A = 1 1 1 1 2 3 1 3 6 B = 1.1270 0 0 0 2.0000 0 0 0 8.8730 y = logical 0 ans = 0.1270 1.0000 7.8730 ans = 1.1270 2.0000 8.8730

5   Pass
A=spiral(3) B=[ 15.738398236975144 0 0 0 -3.388172132922506 0 0 0 -1.350226104052633]; y_correct=1; assert(isequal(Check_Diag(A,B),y_correct))

A = 7 8 9 6 1 2 5 4 3 y = logical 1 ans = 15.7384 -3.3882 -1.3502 ans = 15.7384 -3.3882 -1.3502

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!