shifted triangular matrix array

If I have matrix a=[1 2; 3 4; 5 6; 7 8] (dimension 4x2) and i want to calculate
A= [1 2 0 0 0 0 0 0;
3 4 1 2 0 0 0 0;
5 6 3 4 1 2 0 0;
7 8 5 6 3 4 1 2]
(dimension 4x8),
how can i do?
Thanks.

 採用された回答

Matt J
Matt J 2019 年 12 月 6 日
編集済み: Matt J 2019 年 12 月 6 日

1 投票

ac=num2cell([0,0;a],2);
T=toeplitz(1:4,[1,zeros(1,3)]);
A=cell2mat(ac(T+1))
A =
1 2 0 0 0 0 0 0
3 4 1 2 0 0 0 0
5 6 3 4 1 2 0 0
7 8 5 6 3 4 1 2

3 件のコメント

JESUS DAVID ARIZA ROYETH
JESUS DAVID ARIZA ROYETH 2019 年 12 月 6 日
Excelent!
Image Analyst
Image Analyst 2019 年 12 月 6 日
Jesus, can you "Accept this answer" to give Matt credit for it? Thanks in advance.
SV
SV 2019 年 12 月 6 日
Amazing! Thank for your help

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

質問済み:

SV
2019 年 12 月 6 日

コメント済み:

SV
2019 年 12 月 6 日

Community Treasure Hunt

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

Start Hunting!

Translated by