How to create matrix with array under certain conditions?

1 visualización (últimos 30 días)
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 comentario
José-Luis
José-Luis el 3 de Mayo de 2013
You mean two diagonals? Otherwise two of the values of the resulting matrix are undefined.

Iniciar sesión para comentar.

Respuesta aceptada

Chandrasekhar
Chandrasekhar el 3 de Mayo de 2013
B = [ones(1,3)*A(1); A; ones(1,3)*A(1)]

Más respuestas (0)

Categorías

Más información sobre Operating on Diagonal Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by