Shifting elements and replacing empty places with zeros

1 view (last 30 days)
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

Accepted Answer

Matt J
Matt J on 24 Aug 2023
Edited: Matt J on 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 Comments
Matt J
Matt J on 29 Aug 2023
No, because that would probably be a homework problem.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!