雅可比(jacobi)迭代法 matlab实现

clc clear n = input('请输入矩阵阶数:\n'); for i = 1:n fprintf('请输入矩阵第%d行\n',i); A(i,:) = input(''); end A B(:,1) = input('请输入B向量:\n'); B for i = 1:n x(i) = 0; x2(i) = 0; end for i =1:4 for j = 1:n for k = 1:n if j ~= k x(j) = x(j)-A(j,k)*x2(k); end end x(j)=x(j) + B(j); x(j)=x(j)/A(j,j); end x2=x; for j = 1:n x(j)=0; end fprintf('第%d次迭代结果:\n',i); x2 end

【雅可比(jacobi)迭代法 matlab实现】

    推荐阅读