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