Effacer les filtres
Effacer les filtres

How to write this summation function?

1 vue (au cours des 30 derniers jours)
Felipe Gonzalez
Felipe Gonzalez le 31 Mar 2017
Commenté : Image Analyst le 1 Avr 2017
Hi. I need to write this summation on Matlab and I don't know how.
T_new = ∑x·Tsat
x was written as a vector:
x = linspace (0,1,10)
And Tsat:
for i=1:comp;
Tsat(i)=(C2(i)/(C1(i)-(ln(P)))-C3(i));
end
C1, C2, C3 are constants. There are 2 components (comp). But I need to compute 10 times. At the end, I will plot my code.

Réponse acceptée

Image Analyst
Image Analyst le 31 Mar 2017
Where is Tsat in the formula? All I see is T_new and T. And x has 10 elements while Tsat has comp elements. If comp is not 10, then Tsat and x have different number of elements, so that means T is not in the sum, just x is. So the sum could be written as
T_new = sum(x) - T
  2 commentaires
Felipe Gonzalez
Felipe Gonzalez le 1 Avr 2017
Sorry. There are 2 components. But I need to compute 10 times.
Image Analyst
Image Analyst le 1 Avr 2017
I don't know what that means. sum() will sum all 10 elements of x. So now the first equation, taking your edit into account, becomes this:
T_new = sum(x) - Tsat;
I don't know why you need to do the second chunk of code (the loop) 10 times because it's no different after the 10th time than after the first time, but anyway...put it in a loop:
for k = 1 : 10 % Do the inner loop over "i" 10 times.
for i=1:comp;
Tsat(i)=(C2(i)/(C1(i)-(ln(P)))-C3(i));
end
end
Again Tsat is the same after each iteration of k.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by