How to fast create a specific matrix

조회 수: 2 (최근 30일)
Xiaolong
Xiaolong 2019년 6월 21일
댓글: Xiaolong 2019년 6월 21일
I want to generate a matrix with the same pattern but different size.
pattern: for a matrix with size [4 4]
[ 0 0 0 0;
0 0 0 1;
0 0 1 2;
0 1 2 3]
The matrix is always square. The size is often more than 256 in practice. I can generate this kind of matrix using for-loop. But it's too slow.
How to fast create this kind of matrix?

채택된 답변

Matt J
Matt J 2019년 6월 21일
hankel(zeros(1,4),0:3)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by