I can't find the solution how can i fix this?
1 view (last 30 days)
Show older comments
i=0;
while(1)
xr(1+i) = xr(i)-((exp(-i)-i)/(-exp(-i)-1));
if abs((xr(i+1)-(xr(i))/(xr(i+1)))<=10^(-4));
break
else
i=i+1;
end
end
0 Comments
Answers (1)
Matt J
on 30 Nov 2018
Edited: Matt J
on 1 Dec 2018
You need to distinguish better between the roles of the index i and of the values xr(i) in the code.
clear xr
i=1; xr(1)=0; %initialize
while(1)
a=xr(i); %current point
b = a-((exp(-a)-a)/(-exp(-a)-1)); %next point
xr(i+1)=b; %store
if abs(b-a) <= 10^(-4)*abs(b); %test tolerance
break
else
i=i+1;
end
end
0 Comments
See Also
Categories
Find more on Variables 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!