Shifting elements and replacing empty places with zeros

How to convert matrix A =[3 ,7, 9, 2] to matrix B = [3, 7, 9, 2; 0, 3, 9, 2; 0, 0, 3, 9; 0, 0, 0, 3] using matlab

 Akzeptierte Antwort

Matt J
Matt J am 24 Aug. 2023
Bearbeitet: Matt J am 24 Aug. 2023
The B that you have provided is not what the title of your post describes. I assume you meant the following,
A =[3 ,7, 9, 2];
B=toeplitz([A(1),zeros(1,numel(A)-1)],A)
B = 4×4
3 7 9 2 0 3 7 9 0 0 3 7 0 0 0 3

5 Kommentare

Thank you
@Matt J - Can we do this without using toeplitz function?
Of course!
Can you please on that?
No, because that would probably be a homework problem.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Gefragt:

am 24 Aug. 2023

Kommentiert:

am 29 Aug. 2023

Community Treasure Hunt

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

Start Hunting!

Translated by