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 ExchangeEnvironment 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