modifying an identity matrix
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
cgo
le 9 Août 2022
Réponse apportée : Walter Roberson
le 9 Août 2022
I have an identity matrix. I want to put a '1' on the zeros that are right infront of the main diagonal, except at the very last '1'.
Is there an easy way to do it
0 commentaires
Réponse acceptée
Walter Roberson
le 9 Août 2022
I = eye(7)
r = size(I,1);
newI = diag([ones(1,r-2), 0],-1) + I
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Creating and Concatenating 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!