フィルターのクリア

How to add lower triangle of zeros/indent to each row, in a matrix?

2 ビュー (過去 30 日間)
Amanda
Amanda 2021 年 4 月 25 日
コメント済み: Amanda 2021 年 4 月 25 日
I have this matrix:
1 2 3 4 5 6 7 8 5 5
3 3 3 3 3 4 4 4 5 5
1 4 3 4 3 4 4 4 5 5
3 3 3 3 4 4 4 5 5 5
And I want this as the result:
1 2 3 4 5 6 7 8 5 5 0 0 0
0 3 3 3 3 3 4 4 4 5 5 0 0
0 0 1 4 3 4 3 4 4 4 5 5 0
0 0 0 3 3 3 3 4 4 4 5 5 5
How can I do this as a script?
Please help
Thank you
  1 件のコメント
Catalytic
Catalytic 2021 年 4 月 25 日
It appears that you have not Accept-clicked any of the answers you have been given to your other questions.
Were they all unhelpful?

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

採用された回答

Matt J
Matt J 2021 年 4 月 25 日
編集済み: Matt J 2021 年 4 月 25 日
B=[1 2 3 4 5 6 7 8 5 5
3 3 3 3 3 4 4 4 5 5
1 4 3 4 3 4 4 4 5 5
3 3 3 3 4 4 4 5 5 5];
[m,n]=size(B);
result=spdiags(B,0:n-1,m,n+m-1);
full(result)
ans = 4×13
1 2 3 4 5 6 7 8 5 5 0 0 0 0 3 3 3 3 3 4 4 4 5 5 0 0 0 0 1 4 3 4 3 4 4 4 5 5 0 0 0 0 3 3 3 3 4 4 4 5 5 5
  3 件のコメント
Matt J
Matt J 2021 年 4 月 25 日
You're quite welcome, but please Accept-click the answer to indicate that it resolved the problem.
Amanda
Amanda 2021 年 4 月 25 日
Done

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by