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

John D'Errico
John D'Errico 2018년 2월 17일
What does it mean to "simulate" the anti-diagonals?
Are you asking how to create that array?
It is not clear what your goal is, since you do not seem to be doing something consistent along all the anti-diagonals.
GEORGIOS BEKAS
GEORGIOS BEKAS 2018년 2월 17일
antidiagonal: All elements from the top right element to the the bottom left element. The code describes 5 of them for an indicative 5x5 matrix.
John D'Errico
John D'Errico 2018년 2월 17일
편집: John D'Errico 2018년 2월 17일
Sigh. I know what an anti-diagonal is.
What you have not said is what is your goal. You filled only the first 5 anti-diagonals. Then you stuffed the (5,5) element with a 1. So what are you looking to get? Why did you not fill the other ant-diagonals? How do we know what you are looking for here?
Finally, what does it mean to SIMULATE anti-diagonal?
GEORGIOS BEKAS
GEORGIOS BEKAS 2018년 2월 17일
how can I take the elements of all antidiagonals from any matrix?

댓글을 달려면 로그인하십시오.

답변 (1개)

Steven Lord
Steven Lord 2018년 2월 17일

3 개 추천

Flip the matrix using the flip function then call diag.

댓글 수: 3

GEORGIOS BEKAS
GEORGIOS BEKAS 2018년 2월 17일
I am searching for a code to use it for the other (smaller) anti-diagonals as well.
Roger Stafford
Roger Stafford 2018년 2월 17일
The second argument in the 'diag' function provides for the smaller diagonals, which "flipped" would be the smaller anti-diagonals.
Kaouthar Bouyaouzan
Kaouthar Bouyaouzan 2021년 2월 3일
@Steven Lord Thank you !

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Operating on Diagonal Matrices에 대해 자세히 알아보기

제품

질문:

2018년 2월 17일

댓글:

2021년 2월 3일

Community Treasure Hunt

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

Start Hunting!

Translated by