samedi 15 novembre 2014

Matlab Gaussian Elimination


Vote count:

0





function [C,z,x] = algo3(A,b,n)

C=A
for i = 1:n
z(i)=b(i)
end
for k=1:n

for j=1:k-1
m(j,k)= C(j,k)/C(k,k)
C(j,k:n) = C(j,k:n) - m(j,k)*C(k,k:n)
z(j)=z(j) - m(j,k)*z(k)
end
for j=k+1:n
m(j,k)=C(j,k)/C(k,k)
C(j,k:n) = C(j,k:n) - m(j,k)*C(k,k:n)
z(j)=z(j) - m(j,k)*z(k)
end
C1 = inv(C)
z1 = transpose(z)
x=C1*z1

end


Hi, I have been given this algorithm and I'm currently trying to decipher how it can be used to solve Ax = b. This algorithm takes arguments A,b, and n, where A is an nxn matrix and b is a vector of length n.


The output is an nxn diagonal matrix C, and vector, z, of length n. I find that Cx=z, but im not totally sure why. I have to explain how the outputs C and z computed by this algorithm can be used to find the solution x to Ax = b. I know that once you've found C and z, it is of course really simple to calculate x, but why the this algorithm imply that Cx = z?



asked 51 secs ago







Matlab Gaussian Elimination

Aucun commentaire:

Enregistrer un commentaire