I want to stop loop when Ur is equal to Uo,but it doesn't stop. For example when i put 0.015 for D, Ur is equal to Uo at Uo=544. It doesn't stop at 544 still countinues until it reach 600. And shows Ur for Uo=600. What is wrong with this code? Thank you.
function heatt= heatt(D)
for Uo=20:600
mc=10;
dc=866;
dh=950;
uc=0.097;
uh=0.2700*10^-3;
hfg=2.26*10^6;
Tci=50;
Tco=60;
cpc=2.03*10^3;
L=1.72;
Nprc=795;
Nprh=1.5;
q=mc*cpc*(Tco-Tci);
Thi=100;
Tho=100;
kc=0.014;
kh=0.6818;
hdi=5555;
hdo=1500;
Tlm=Thi-(Tco+Tci)/2;
mh=q/hfg
Ao=q/(Uo*Tlm);
n=Ao/(3.14*D*L)
vc=mc/(dc*3.14*D^2/4*n);
Nrec=vc*dc*D/uc;
if Nrec>2100
hi=n*kc*0.027*Nrec^0.8*Nprc^(1/3)/D;
else
hi=n*kc*1.86*(Nrec*Nprc*D/L)^(1/3)/D;
end
ho=0.725*(dh*dh*9.81*hfg*D^3/(n*uh*kh*45))^(1/4)*kh/D;
Ur=1/(1/ho+1/hi+1/hdo+1/hdi)
if Ur==Uo
break
end
end
end

 채택된 답변

the cyclist
the cyclist 2016년 12월 29일
편집: the cyclist 2016년 12월 29일

0 개 추천

Because of floating point error, they are probably not exactly equal. Try something like
tol = 1.e-12;
if abs(Ur-Uo) < tol;
...
You might need to adjust the tolerance.

댓글 수: 1

fff fff
fff fff 2016년 12월 29일
Thank you. This is what i was look for.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Environment and Settings에 대해 자세히 알아보기

질문:

2016년 12월 29일

편집:

2016년 12월 30일

Community Treasure Hunt

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

Start Hunting!

Translated by