MATLAB Answers

shifted triangular matrix array

2 views (last 30 days)
SV
SV on 6 Dec 2019
Commented: SV on 6 Dec 2019
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.

  0 Comments

Sign in to comment.

Accepted Answer

Matt J
Matt J on 6 Dec 2019
Edited: Matt J on 6 Dec 2019
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 Comments

Image Analyst
Image Analyst on 6 Dec 2019
Jesus, can you "Accept this answer" to give Matt credit for it? Thanks in advance.
SV
SV on 6 Dec 2019
Amazing! Thank for your help

Sign in to comment.

More Answers (0)

Sign in to answer this question.