What is the function for receiving a vector that will contain the elements of the second diagonal?
Info
This question is closed. Reopen it to edit or answer.
Show older comments
I know that the function for the main diagonal is diag. Is there a function for the second diagonal? If not, how can I find it?
Answers (2)
dpb
on 5 Apr 2018
1 vote
Read the input description; there's a second optional argument to diag
Steven Lord
on 5 Apr 2018
0 votes
From the documentation for diag: "x = diag(A,k) returns a column vector of the elements on the kth diagonal of A." and "k=0 represents the main diagonal, k>0 is above the main diagonal, and k<0 is below the main diagonal."
The second example on that documentation page shows how to use that syntax.
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!