⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chaosong.m

📁 fit programme for a serials of data
💻 M
字号:
function [X,n]=chaosong(A,b,X0,omige,e,N0)
% input A is an N*N nonsingular matrix
%       b is an N*1 matrix
%       e is the tolerance for iterations
%       X0 is an N*1 matrix,the initial guess of AX=b
%       omige is the slack coefficient of iterations
% output X is an N*1 matrix; the jacobi iterations approximation to 
%        the solution of AX=b
%         N0 is the maximum number of iterations
%rou=norm(eig(A));
%if rou>=1
%   disp(sprintf('the process of iteration is diverge'));
%  return;
%end
N=length(b);
X=X0;
for n=1:N0
    error=0;
    for i=1:N
        t=X(i);
        X(i)=X(i)+(b(i)-A(i,1:N)*X(1:N))*omige/A(i,i);
%        X(i)=b(i);
%       for j=1:N
%            if j~=i
%               X(i)=X(i)-A(i,j)*X(j); 
%            end
%        end
%        X(i)=X(i)*omige/A(i,i);
        if abs(X(i)-t)>error
           error=abs(X(i)-t);
        end
    end
    if error<e
       return; 
    end
end
disp(sprintf('false'))

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -