(Anti)diagonal automation

146 views (last 30 days)
GEORGIOS BEKAS
GEORGIOS BEKAS on 17 Feb 2018
Counting from the top right element to the the bottom left element of an indicative 5x5 matrix, is there a quick way to automate the simulation of all the antidiagonals?
a(1,1) =1
a(2,1) =2
a(1,2) =2
a(3,1)= 3
a(2,2)=3
a(1,3)=3
a(4,1)=4
a(2,3)=4
a(3,2)=4
a(1,4)=4
a(1,5)=5
a(4,2)=5
a(3,3)=5
a(2,4)=5
a(5,1)=5
a(5,5)=1
  4 Comments
GEORGIOS BEKAS
GEORGIOS BEKAS on 17 Feb 2018
how can I take the elements of all antidiagonals from any matrix?

Sign in to comment.

Answers (1)

Steven Lord
Steven Lord on 17 Feb 2018
Flip the matrix using the flip function then call diag.
  3 Comments

Sign in to comment.

Categories

Find more on Operating on Diagonal Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!