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

Learn moreOpportunities for recent engineering grads.

Apply TodayAccess the diagonal elements of a matrix without 'diag' function

47 correct solutions
63 incorrect solutions

Last solution submitted on Sep 27, 2015

1 Comment

Khaled Hamed
on 30 Dec 2012

Right solution to right problem

1 Comment

Duane Hanselman
on 30 Dec 2012

Test #5 is incorrect. Transpose on x makes the diagonal [1 5 9], [1 6 11] are not on any diagonal. #5 is the transpose of #4 and taking the transpose does not change the diagonal, unless you have some other definition for diagonal. A good solution is x(find(eye(size(x))))

1 Comment

Khaled Hamed
on 30 Dec 2012

Rigt solution for wrong problem

1 Comment