How to write this summation function?
2 views (last 30 days)
Show older comments
Felipe Gonzalez
on 31 Mar 2017
Commented: Image Analyst
on 1 Apr 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.
0 Comments
Accepted Answer
Image Analyst
on 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 Comments
Image Analyst
on 1 Apr 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.
More Answers (0)
See Also
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!