why while loop won't perform last iteration?
Afficher commentaires plus anciens
I'm using this function:
function [ tf,ca ] = Implicit_Trapizoidal_Method( ca0, t0, tf, dt )
t=t0+dt;
while t<=tf
ca=ca0+(dt/2)*(f_function(ca0)+f_function(successive_substitution(ca0,dt,ca0,5)));
ca0=ca;
t0=t;
t=t+dt;
end
tf=t0;
end
when I enter the command (for example):
[ tf,ca ] = Implicit_Trapizoidal_Method( 0.0095, 0, 1,0.1)
I receive a logical answer where tf=1 just like I expected, but when I enter the command:
[ tf,ca ] = Implicit_Trapizoidal_Method( 0.0095, 0, 0.3,0.1)
I receive tf=0.2 for some reason... It happens with more numbers like 1.4, 3 and so on.
I would love to get some help, thanks.
Réponse acceptée
Plus de réponses (1)
Catégories
En savoir plus sur Logical dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!