Cody

# Problem 42752. Matrix diagonalization

Solution 1681766

Submitted on 27 Nov 2018 by Martin C.
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 v = -0.5774 -0.8131 -0.3416 -0.5774 0.4714 -0.4714 -0.5774 0.3416 0.8131 s = 15.0000 0 0 0 4.8990 0 0 0 -4.8990 y = logical 1

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

v = 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 s = 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 y = logical 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 v = -0.7071 -0.4472 0.7071 -0.8944 s = -1 0 0 5 y = logical 0

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 v = -0.5438 -0.8165 0.1938 0.7812 -0.4082 0.4722 -0.3065 0.4082 0.8599 s = 0.1270 0 0 0 1.0000 0 0 0 7.8730 y = logical 0

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 v = -0.8093 -0.5764 0.1093 -0.3892 0.8151 -0.7911 -0.4399 -0.0592 0.6018 s = 15.7384 0 0 0 -3.3882 0 0 0 -1.3502 y = logical 1

### Community Treasure Hunt

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

Start Hunting!