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개)

James Tursa
James Tursa 2018년 4월 9일

0 개 추천

See if this link helps you understand what is going on with your floating point calculations:

댓글 수: 1

Thank you. But i so bad english and i just begin use matlab. I can't understand that post in your link. Can you help me directly on my code.... :(. Thank you again.

이 질문은 마감되었습니다.

태그

질문:

2018년 4월 9일

마감:

2021년 8월 20일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by