graph of iterative sequence
Show older comments
how can i get the graph of this iterative sequence
t=@(n)(1/(n+2)^2);r=1/5;
g=@(x)((x-1)/(exp(x)));
tolerance=0.000001;
k=100;
x=zeros(1,k);
x(1)=0.3977;
for n=1:k
x(n+1)=(1-(r)*g(x(n)))*(1-t(n))*x(n);
if abs(x(n+1)-x(n))<tolerance
fprintf('The sequence converges after %d iterations for tolerance = %f', n, tolerance)
break;
end
end
x=x(1:n+1); %discard the zeros
format long
disp(x)
Accepted Answer
More Answers (0)
Categories
Find more on App Building 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!