What happen with my code????, please help me fix this!!
정보
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
이전 댓글 표시
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
Stephen23
2018년 4월 16일
Floating-point numbers have been explained many times on this forum:
etc, etc, etc
답변 (1개)
James Tursa
2018년 4월 9일
0 개 추천
See if this link helps you understand what is going on with your floating point calculations:
댓글 수: 1
nam tran
2018년 4월 9일
이 질문은 마감되었습니다.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!