Effacer les filtres
Effacer les filtres

How to create matrix with array under certain conditions?

1 vue (au cours des 30 derniers jours)
Yun Inn
Yun Inn le 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 commentaire
José-Luis
José-Luis le 3 Mai 2013
You mean two diagonals? Otherwise two of the values of the resulting matrix are undefined.

Connectez-vous pour commenter.

Réponse acceptée

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

Plus de réponses (0)

Catégories

En savoir plus sur Resizing and Reshaping Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by