What happen with my code????, please help me fix this!!
Info
This question is closed. Reopen it to edit or answer.
Show older comments
When I test f=1.991, i have result Fkq=1.9908

But when I use 'for' i have result Fkq=1.9523 (f=1.925) and Fkq=1.9524 (f=1.9530) then it stop increase f.

Please someone help me resolve this problem, why f do not increase 1.954,1.955..... This is my code:
w= [40000 120000 200000 220000 100000]; gama= [0.0995 0.0995 0.0995 0.1972 0.7854];
n=length(w); c=500;
b=40; phi=0.314; SFm=0; SFt=0;
%f=1.991;
for f=1:0.001:2
for i=1:n
Fm(i)=w(i)*tan(gama(i));
T(i)=(c*b*sec(gama(i))+w(i)*sec(gama(i))*tan(phi))/(f+tan(gama(i))*tan(phi));
Ft(i)=(((c*b*sec(gama(i))+(w(i)*sec(gama(i))-T(i)*tan(gama(i)))*tan(phi))*sec(gama(i))));
end
for i=1:n
SFm = SFm + Fm(i);
SFt = SFt + Ft(i);
end
Fkq = SFt/SFm;
if abs(f-Fkq) <= 0.001
disp(Fkq)
end
end
1 Comment
Stephen23
on 16 Apr 2018
Floating-point numbers have been explained many times on this forum:
etc, etc, etc
Answers (1)
James Tursa
on 9 Apr 2018
0 votes
See if this link helps you understand what is going on with your floating point calculations:
1 Comment
nam tran
on 9 Apr 2018
This question is closed.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!