Ältere Kommentare anzeigen
hi,
is there a quick way to change the values of the diagonal of a matrix, instead of
for i = 1:length(A)
A(i,i) = 0;
end
thx
1 Kommentar
Andrei Bobrov
am 8 Dez. 2011
A-diag(diag(A))
Akzeptierte Antwort
Weitere Antworten (1)
Sean de Wolski
am 8 Dez. 2011
One way:
A = magic(100); %sample matrix
A(logical(speye(length(A)))) = 0;
Also diag if you're building a matrix
Kategorien
Mehr zu Creating and Concatenating Matrices finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!