반응형
function [root, ea, iter] = FixedPoint(func, xr, es, maxiter)
if nargin < 3
es = 1.0;
end
if nargin < 4
maxiter = 50;
end
iter = 1;
fprintf('iter = %d: xr = %.4f\n', iter, xr);
while(1)
xrold = xr;
xr = func(xrold);
ea = abs((xr - xrold) / xr) *100;
iter = iter + 1;
fprintf('iter = %d: xr = %.4f, es = %.2f\n', iter, xr, ea);
if (ea <= es) || (iter > maxiter)
break;
end
end
root = xr;
반응형
'기계공학 > Numerical Method (수치해석)' 카테고리의 다른 글
[수치해석] Bisection Method Matlab Code (0) | 2021.04.17 |
---|---|
[수치해석] Linear Interpolation Matlab Code (0) | 2021.04.17 |
[수치해석] Newton-Raphson Method Matlab Code (0) | 2021.04.17 |