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

 採用された回答

Matt J
Matt J 2023 年 8 月 24 日
編集済み: Matt J 2023 年 8 月 24 日

0 投票

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 件のコメント

Ritu Giri
Ritu Giri 2023 年 8 月 25 日
Thank you
Ritu Giri
Ritu Giri 2023 年 8 月 29 日
@Matt J - Can we do this without using toeplitz function?
Matt J
Matt J 2023 年 8 月 29 日
Of course!
Ritu Giri
Ritu Giri 2023 年 8 月 29 日
Can you please on that?
Matt J
Matt J 2023 年 8 月 29 日
No, because that would probably be a homework problem.

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

その他の回答 (0 件)

カテゴリ

質問済み:

2023 年 8 月 24 日

コメント済み:

2023 年 8 月 29 日

Community Treasure Hunt

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

Start Hunting!

Translated by