Effacer les filtres
Effacer les filtres

problem in inserting a diagnol

1 vue (au cours des 30 derniers jours)
k.v.swamy
k.v.swamy le 12 Juil 2012
hi, i have a problem in inserting the diagnol of a matrix. i have a=[1 2 3;4 5 6;7 8 9] in which i have to extract the diagnol by multiplying with 2 and i want to again insert the diagnol i,e iwant to have [2 2 3;4 10 6;7 8 18]; i dont want to use the loop.
  3 commentaires
Yash
Yash le 12 Juil 2012
how do u want the output to be
San
San le 12 Juil 2012
he want to have double for diagonal but don't want loop :(

Connectez-vous pour commenter.

Réponses (1)

Conrad
Conrad le 12 Juil 2012
A = [ 1 2 3;...
4 5 6;...
7 8 9];
A(1:(length(A)+1):numel(A)) = 2*diag(A);

Catégories

En savoir plus sur Multidimensional Arrays 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