Algorithme des Disques de Gershgorin en Matlab :
function gershcircles(A) %GERSHCIRCLES trace les disques de Gershgorin % GERSHCIRCLES(A) trace les disques de Gershgorin % pour la matrice carrée A et sa transposée. n = size(A); if n(1) ~= n(2) error(’Matrices carrées seulement’); else n=n(1); circler=zeros(n ,201); circlec=circler; end center = diag(A); radiic = sum(abs(A-diag(center ))); radiir = sum(abs(A’-diag(center ))); one = ones (1,201); cosisin = exp(i*[0:pi/100:2* pi]); figure (1); title(’Disques des lignes ’); xlabel(’Re’); ylabel(’Im’); figure (2); title(’Disques des colonnes ’); xlabel(’Re’); ylabel(’Im’); for k = 1:n circlec(k,:) = center(k)*one + radiic(k)*cosisin ; circler(k,:) = center(k)*one + radiir(k)*cosisin ; figure (1); patch(real(circler (k,:)) ,imag(circler (k,:)) ,’red’); hold on plot(real(circler(k,:)) ,imag(circler(k,:)) ,’k-’ ,... real(center(k)),imag(center(k)),’kx’); figure (2); patch(real(circlec (k,:)) ,imag(circlec (k,:)) ,’green’); hold on plot(real(circlec(k,:)) ,imag(circlec(k,:)) ,’k-’ ,... real(center(k)),imag(center(k)),’kx’); end for k = 1:n figure (1); plot(real(circler(k,:)) ,imag(circler(k,:)) ,’k-’ ,... real(center(k)),imag(center(k)),’kx’); figure (2); plot(real(circlec(k,:)) ,imag(circlec(k,:)) ,’k-’ ,... real(center(k)),imag(center(k)),’kx’); end figure (1); axis image; hold off; figure (2); axis image; hold off return |
Aucun commentaire:
Enregistrer un commentaire