Iteration loop for a function to reach a certain value.

3 次查看(过去 30 天)
Hello, I want to write an iteration loop for a function that needs an innitial guess. The equations work off of each other and thus a first guess is needed to find an answer, the method is as follows: Tc is the first guess, then 3 seperate values are found using the initial guess of Tc, and finally a new Tc is found utilizing the previous 3 values found. The final Tc value must be close to the initial guess for the answer to be correct and that is why I want the iteration loop to occur. Thank you in advance!
%the "+273.15" serves to convert celcius to kelvin
g=9.81;
NU=2.52;
k=.0293;%from book
L=.025;%plate to cover spacing m
sigma=5.6697e-8;
epsilonp=0.95;%plate emittance
epsilonc=0.88;%glass emittance
Ts=10+273.15;%ambient sky temp K
Tp=60+273.15;%mean plate temp K
Tc=35+273.156;%assumed collector temp K, this is the desired iterated value
hcpc=NU*(k/L);%conv. heat trans coeff
hw=10;
hrpc=((sigma*(Tp^2+Tc^2)*(Tp+Tc))/((1/epsilonp)+(1/epsilonc)-1));%rad conv
%between plate and collector
hrca=epsilonc*sigma*(Tc^2+Ts^2)*(Tc+Ts);%rad. coeff for cover to air
Ut=((1/(hcpc+hrpc))+(1/(hw+hrpc)))^-1;%top loss coeff from collector to ambient
Tc=Tp-((Ut*(Tp-Ts)/(hcpc+hrpc)));%this value must get close to value of original guess

采纳的回答

Torsten
Torsten 2024-3-9
g=9.81;
NU=2.52;
k=.0293;%from book
L=.025;%plate to cover spacing m
sigma=5.6697e-8;
epsilonp=0.95;%plate emittance
epsilonc=0.88;%glass emittance
Ts=10+273.15;%ambient sky temp K
Tp=60+273.15;%mean plate temp K
Tc=35+273.156;%assumed collector temp K, this is the desired iterated value
Tcnew = Inf;
hcpc=NU*(k/L);%conv. heat trans coeff
hw=10;
tol = 1e-6;
format long
while abs(Tc-Tcnew) > tol
Tcnew = Tc;
hrpc=((sigma*(Tp^2+Tc^2)*(Tp+Tc))/((1/epsilonp)+(1/epsilonc)-1));%rad conv
%between plate and collector
hrca=epsilonc*sigma*(Tc^2+Ts^2)*(Tc+Ts);%rad. coeff for cover to air
Ut=((1/(hcpc+hrpc))+(1/(hw+hrpc)))^-1;%top loss coeff from collector to ambient
Tc=Tp-((Ut*(Tp-Ts)/(hcpc+hrpc)));%this value must get close to value of original guess
Tc
end
Tc =
3.012549948434458e+02
Tc =
3.011481167433821e+02
Tc =
3.011464601619294e+02
Tc =
3.011464344851034e+02
Tc =
3.011464340871154e+02

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 General Physics 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by