How can I create a matrix with diagonal structure that is neither upper nor lower triangular matrix?

조회 수: 1 (최근 30일)
Hello everyone,
I would like to create a matrix of the following structure on a large scale:
B=[2 3 4 5 6; 3 4 5 6 0; 4 5 6 0 0; 5 6 0 0 0; 6 0 0 0 0]
B = 5×5
2 3 4 5 6 3 4 5 6 0 4 5 6 0 0 5 6 0 0 0 6 0 0 0 0
How can I do this in an efficient manner?
Thank you

채택된 답변

Stephen23
Stephen23 2022년 3월 3일
hankel(2:6)
ans = 5×5
2 3 4 5 6 3 4 5 6 0 4 5 6 0 0 5 6 0 0 0 6 0 0 0 0

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Operating on Diagonal Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by