How to create matrix with array under certain conditions?

7 Ansichten (letzte 30 Tage)
Yun Inn
Yun Inn am 3 Mai 2013
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 Kommentar
José-Luis
José-Luis am 3 Mai 2013
You mean two diagonals? Otherwise two of the values of the resulting matrix are undefined.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Chandrasekhar
Chandrasekhar am 3 Mai 2013
B = [ones(1,3)*A(1); A; ones(1,3)*A(1)]

Weitere Antworten (0)

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by