Professional Documents
Culture Documents
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Outputs from this function are returned to the command line.
function varargout = jacobi_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[x,n]=yakebi(A,b,x0,eps,M);
set(handles.x_text,'String',strcat(num2str(x)));
set(handles.n_edit,'String',strcat(num2str(n)));
close
function [x,n]=yakebi(A,b,x0,eps,M)
if nargin==3
eps= 1.0e-6;
M = 10000;
elseif nargin ==4
M =10000;
end
D=diag(diag(A)); %A
L=-tril(A,-1); %A
U=-triu(A,1); %A
B=D\(L+U);
f=D\b;
x=x0;
n=0;
tol=1;
x=x';
while tol>=eps
x=x';
x=B*x0+f;
n=n+1;
tol=norm(x-x0);
x0=x;
x=x';
if(n>=M)
return;
end
end