高斯迭代法MATLAB程序:function[x]=gauss(a,b)n=length(a);x=zeros(n,1);a=[ab];fork=1:n-1max=k;fori=k+1:nifa(i,k)a(max,k)max=i;endendtemp=a(k,k:n+1);a(k,k:n+1)=a(max,k:n+1);a(max,k:n+1)=temp;fori=k+1:na(i,k)=-a(i,k)/a(k,k);a(i,k+1:n+1)=a(i,k+1:n+1)+a(i,k)*a(k,k+1:n+1);endendx(n,1)=a(n,n+1)/a(n,n);fori=n-1:-1:1sum=0;forj=i+1:nsum=sum+x(j,1)*a(i,j);endx(i,1)=(a(i,n+1)-sum)/a(i,i);end窗口命令:Gaussa=[034;1-11;212];b=[1;2;3];gauss(a,b)运行结果: