Please help me in coding of multidimensional array
Afficher commentaires plus anciens
Hi,
I will like to run the following code,
A =
[1 2 3 4 5 6;
4 0 6 -1 2 4;
-2 4 0 -10 11 56;
0 -10 -25 28 45 52;
-8 -6 0 -15 0 28;
-7 -28 -45 0 -75 52;]
In the above matrix, if the diagonal term is zero then that row and column should be deleted and it gives the final matrix as
A =
[1 4 6;
0 28 52;
-7 0 52;]
Réponse acceptée
Plus de réponses (2)
Roger Stafford
le 27 Oct 2017
A = A([1,4,6],[1,4,6]);
Andrei Bobrov
le 27 Oct 2017
ii = find(diag(A))
out = A(ii,ii)
Catégories
En savoir plus sur Operating on Diagonal Matrices dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!