フィルターのクリア

How can I do this matrix ?

1 回表示 (過去 30 日間)
zeezo
zeezo 2018 年 2 月 20 日
コメント済み: zeezo 2018 年 2 月 21 日
I have this Matrix
A=[1;6;9;4;2;8]
I would like to generate a matrix as follow
the first row has only 1 and the rest zeros.
the seconds row has 1 and 6 and the rest zeros
the third has 1 , 6 and 9 and the rest zeros and so one
B=
1 0 0 0 0 0
1 6 0 0 0 0
1 6 9 0 0 0
1 6 9 4 0 0
1 6 9 4 2 0
1 6 9 4 2 8
How can I do it ?

採用された回答

Stephen23
Stephen23 2018 年 2 月 20 日
編集済み: Stephen23 2018 年 2 月 20 日
>> A = [1;6;9;4;2;8];
>> M = tril(repmat(A.',6,1))
M =
1 0 0 0 0 0
1 6 0 0 0 0
1 6 9 0 0 0
1 6 9 4 0 0
1 6 9 4 2 0
1 6 9 4 2 8
  4 件のコメント
Stephen23
Stephen23 2018 年 2 月 20 日
zeezo
zeezo 2018 年 2 月 21 日
Thanks a lot

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by