Problem with fzero function
显示 更早的评论
I had some troubles in using fzero.
Here is my script: lambda=0.23; T_orb=86400; D=130*1000; omega=2*pi/T_orb; distance=1000*[37700;38400;39000;39600]; for q=1:4 APS.tint(q)=fzero(@(T_int)[distance(q)*lambda/(2*D/2*-(cos(omega*T_int+omega*(T_orb/4-T_int/2))-cos(omega*(T_orb/4-T_int/2))))-2000],100);
end
and it gives me as result tint=[1.527152190882263e-12 1.527032893943011e-12 1.526723991273891e-12 1.527144367230523e-12], but using this values the function has not a zero! Using a bigger first guess (like 1000) it finds the correct first solution (the function is periodical). Why it gives me this result of magnitude 10^-12?
1 个评论
jgg
2016-2-22
If your function is non-linear, fzero can find local near-zeroes. You will want to trial it from several points.
I can't debug your code further because you didn't include lambda.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Numeric Solvers 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!