Bonjour,
quelqu'un aurait-il un programme permettant (sous matlab) de calculer l'inverse d'une matrice?
je ne parle pas de la méthode préprogrammé "inv()" mais d'un programme entier svp..
merci d'avance
function B = calcul_inverse_gauss(A)
n=size(A,1);
B=eye(n);
for p=1:n
vec=[(1:p-1) n (p:n-1)];
test=1;
while A(p,p)==0
if test==n
error('La matrice n''est pas inversible')
end
A=A(vec,:);
B=B(vec,:);
test=test+1;
end
B(p,:)=B(p,:)/A(p,p);
A(p,:)=A(p,:)/A(p,p);
for q=p+1:n
B(q,:)=B(q,:)-A(q,p)*B(p,:);
A(q,:)=A(q,:)-A(q,p)*A(p,:);
end
end
for p=n:-1:2
for q=p-1:-1:1
B(q,:)=B(q,:)-A(q,p)*B(p,:);
A(q,:)=A(q,:)-A(q,p)*A(p,:);
end
end
function determinant = calcul_determinant(M)
determinant=0;
if size(M,1)==1
determinant = M;
else
for p=1:size(M,1)
Mm=M;
Mm(:,1)=[];
Mm(p,:)=[];
determinant = determinant + (-1)^(p+1)*M(p,1)*calcul_determinant(Mm);
end
end
function inverse = calcul_inverse(M)
inverse=zeros(size(M,1));
for p=1:size(M,1)
for q=1:size(M,1)
Mm=M;
Mm(p,:)=[];
Mm(:,q)=[];
inverse(p,q) = (-1)^(p+q)*calcul_determinant(Mm);
end
end
inverse = inverse.'/calcul_determinant(M);
Combien cela coûte-t-il au total ? Quelles aides apportent l'état et les acteurs du marché pour alléger cette charge non choisie ? Tous les détails sur Commentçamarche.net.
par contre dsl je suis très novice dans matlab, j'ai pas trop compris la phase:
for p=1:n
vec=[(1:p-1) n (p:n-1)];
test=1;
while A(p,p)==0
if test==n
error('La matrice n''est pas inversible')
end
A=A(vec,:);
B=B(vec,:);
test=test+1;
end
peux tu m'expliquer
merci d'avance
B=eye(n)
Le n c'est quoi dans ce cas la?
Est-ce le nombre de rangees?