1Gauss-Seidel迭代法的程序functionx=Gauss_Seidel(A,b)[m,n]=size(A);x0=zeros(n,1);x=zeros(n,1);k=0;fori=1:nx(i)=b(i);forj=1:i-1x(i)=x(i)-A(i,j)*x(j);endforj=i+1:nx(i)=x(i)-A(i,j)*x0(j);endx(i)=x(i)/A(i,i);endxwhilenorm(x-x0)1e-10k=k+1;x0=x;fori=1:nx(i)=b(i);forj=1:i-1x(i)=x(i)-A(i,j)*x(j);endforj=i+1:nx(i)=x(i)-A(i,j)*x0(j);endx(i)=x(i)/A(i,i);endxendk