Given a matrix A and a diagonal index d (where 0 indicates the main diagonal and off-diagonals are identified by positive and negative integers), return the indices of the elements of this diagonal.
d is always correct but A can contain repetitions, so ...
Solution Stats
Problem Comments
2 Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers71
Suggested Problems
-
Find the longest sequence of 1's in a binary sequence.
6677 Solvers
-
Flag largest magnitude swings as they occur
689 Solvers
-
Replace Nonzero Numbers with 1
442 Solvers
-
120 Solvers
-
String Array Basics, Part 1: Convert Cell Array to String Array; No Missing Values
1956 Solvers
More from this Author43
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
Need a test case with a 0 on the chosen diagonal.
Agree with Jon's comment that the matrix should contain 0 elements