How can I write a matlab code for this iterative function.
Ältere Kommentare anzeigen
x(n+1)=(1/(n+1)+(1-(1/(n+1)))*x(n)+5*(x(n)-1)/(exp(x(n))))
3 Kommentare
Dyuman Joshi
am 6 Apr. 2023
What is the value of the first element of the sequence? You have written the equation, you need to add a loop or you can use recursion.
Walter Roberson
am 6 Apr. 2023
are you sure it is 1/n+1 and not 1/(n+1) ?
biratu lemessa
am 6 Apr. 2023
Akzeptierte Antwort
Weitere Antworten (1)
% initial value of x(0)
x = 0;
for n=1:10
x = (1/n)- (1-(1/n+1)) *x +5*exp(x); % check the formula. this one is diverging
fprintf("i=%3d x=%9.3f\n", i, x)
end
1 Kommentar
biratu lemessa
am 6 Apr. 2023
Kategorien
Mehr zu Function Creation finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!