why while loop won't perform last iteration?
显示 更早的评论
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.
采纳的回答
更多回答(1 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!