Cody

# Problem 1057. Given a matrix, return the last eigen value

Solution 1062399

Submitted on 27 Nov 2016 by JAEHYUK WOO
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
x = [1 2 3 0 4 3 2 5 -1 0 0 0 2 3 4 3 2 5 4 0 -9 0 0 -2 -3]; k = eig(x); y_correct = k(end); assert(isequal(last_eig(x),y_correct))

ans = -1.7849 + 2.6263i -1.7849 - 2.6263i 1.4184 + 4.5789i 1.4184 - 4.5789i 6.7330 + 0.0000i ans = 6.7330

2   Pass
x = [1 2 3 6 4 -1 -9 1 3]; k = eig(x); y_correct = k(end); assert(isequal(last_eig(x),y_correct))

ans = 1.1967 + 4.4888i 1.1967 - 4.4888i 5.6067 + 0.0000i ans = 5.6067

3   Pass
x = magic(6); k = eig(x); y_correct = k(end); assert(isequal(last_eig(x),y_correct))

ans = 111.0000 27.0000 -27.0000 9.7980 -0.0000 -9.7980 ans = -9.7980

### Community Treasure Hunt

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

Start Hunting!