Creating a loop to solve for variables

3 次查看(过去 30 天)
Kemal
Kemal 2013-6-18
Hello,
I am trying to generate a loop which calculates the roots for the third degree polynomial going through all the values in the m vector. Then, I want to sort the positive roots into a new vector, which will be rc and then use these new values to calculate the variables of interest, which are Ac and LEct. I define most of the variables to be used except m and rc. Rc will change based on different values of m and subsequently, the values of Ac and LEct will, too. I have done some work already which I have included below but I don't know enough programming to build more on this. Any help will be much appreciated. Thank you!
qCiCa = 0.71;
betan = 0.08;
Ca=360;
alpha = (Ca*(qCiCa-0.2) /(betan*fAPAR2*PARi2)) + 0.2*(1.3*rb2 + ra2);
m=[0.5 1.5 2.5 3.5 4.5 5.5 6.5 7.5 8.5];
for i=1:length(m)
rcall=[];
C1 = (alpha*bc2 - 1.6*(1-bc2*rb2) + (1-0.2)*m(i)*RH2)/(1.6*bc2);
C2 = (-alpha*(1-bc2*rb2) - 1.6*rb2 + (1-0.2)*m(i)*rb2)/(1.6*bc2);
C3 = (-alpha*rb2)/(1.6*bc2);
syms x;
f = x^3 + C1(i,:)*x^2 + C2(i,:)*x + C3(i,:); C = [1 C1(i,:) C2(i,:) C3(i,:)];
r = roots(C(i,:));
rcall = [rcall r];
end
Ac = (Ca*betan*fAPAR2*PARi2*(1-0.2))/ (Ca*(qCiCa-0.2) + betan*fAPAR2*PARi2.*(1.6*rc+1.3*rb2+ra2));
LEct = (lambda2*VPD2)./(Patm.*(rc+rb2));

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by