simple Fixed Point Iteration
Show older comments
clear all;
clc;
x(1)=0;
g=@(x) exp(-x);
f=@(x) exp(-x)-x;
true_root=0.56714329;
disp('----------------------------------------------------');
disp('i xi Ea(%) Et(%) ');
disp('----------------------------------------------------');
for i=1:10
x(i+1)=g(x(i));
end
if x~=0
ea=100*abs(x(i+1)-g(x(i))/x(i+1));
end
e_t=100*abs(x-true_root)/true_root;
res=[[0:10]' x' ea' e_t'];
fprintf('%d %1.6f %3.3f %3.3f\n', res');
i want to add the ea. but i can. how can i this??
Accepted Answer
More Answers (0)
Categories
Find more on Surface and Mesh Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!