I can't find the solution how can i fix this?

1 view (last 30 days)
john parker
john parker on 30 Nov 2018
Edited: Matt J on 1 Dec 2018
Ekran Alıntısı.PNG
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

Answers (1)

Matt J
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

Categories

Find more on Variables in Help Center and File Exchange

Products


Release

R2016a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!