Help with "While" loop, not sure what I'm doing
Mostra commenti meno recenti
I have started learning to use Matlab, I have a program that a colleague of mine has written for processing my data and I can't figure out why some of the script is not working. In the following loop, the first equation (RHlsun) uses the original value of glsuni istead of the new value from the loop. I hope this makes sense. What am I doing wrong?
counter = 0;
glsuni = 0.5;
glsun = 0.0;
converge1 = abs(glsuni - glsun);
while converge1>0.0005;
RHlsun = 1 - (1 - (RH / 100)) .* (((2 * glsuni * ((fgreen * fdry) / fstomata)) .* gvl .* (gbc ./ LAIsun)) ./ ((2 * glsuni .* ((fgreen * fdry) / fstomata)) .* ((2 * glsuni .* ((fgreen * fdry) / fstomata)) .* gvl + (2 * glsuni .* ((fgreen * fdry) / fstomata)) .* (gbc ./ LAIsun) + gvl .* (gbc ./ LAIsun))));
sRHlsun = (sqrt((RHlsun.^2) + (RHlmin^2))) ./ (sqrt(1 + (RHlmin^2)));
CO2lsun = CO2i - (CO2i - CO2a) * (((2 * 0.625 * glsuni * ((fgreen * fdry) / fstomata)) .* gcl .* (gbc ./ LAIsun)) ./ ((2 * 0.625 * glsuni * ((fgreen * fdry) / fstomata)) .* ((2 * 0.625 * glsuni .* ((fgreen * fdry) / fstomata)) .* gcl + (2 * 0.625 * glsuni * ((fgreen * fdry) / fstomata)) .* (gbc ./ LAIsun) + gcl .* (gbc ./ LAIsun))));
glsun = mBWB .* ((Ansun .* sRHlsun) ./ CO2lsun) + bBWB;
counter = counter + 1;
converge1 = abs(glsuni - glsun);
glsuni = glsun;
if counter > 30;
break;
end;
end;
Risposta accettata
Più risposte (0)
Categorie
Scopri di più su Parallel Computing in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!