Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Solution 171843

Submitted on 3 Dec 2012 by James

Correct

17Size
Leading solution size is 11.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
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 =
    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 =
    5.6067
3
Pass
 
%%
x = magic(6);
k = eig(x);
y_correct = k(end);
assert(isequal(last_eig(x),y_correct))
ans =
   -9.7980