How to create matrix with array under certain conditions?

1 回表示 (過去 30 日間)
Yun Inn
Yun Inn 2013 年 5 月 3 日
I have an array:
A=[1.3 1.2 1.3]
How can I get matrix B using A?
B=[1.3 1.3 1.3; 1.3 1.2 1.3; 1.3 1.3 1.3]
Matrix B has the value of A at the central row,column,and diagonal.
  1 件のコメント
José-Luis
José-Luis 2013 年 5 月 3 日
You mean two diagonals? Otherwise two of the values of the resulting matrix are undefined.

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

採用された回答

Chandrasekhar
Chandrasekhar 2013 年 5 月 3 日
B = [ones(1,3)*A(1); A; ones(1,3)*A(1)]

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by