Symbolic array summation in MATLAB
Show older comments
I am trying to output the following symbolic expression in MATLAB: How can I genereate this?
10*L(1) + 20*L(2) + 30*L(3) + 10*L(4) + 20*L(5) + 30*L(6) + 10*L(7) + 20*L(8) + 30*L(9);
This is my code:
syms J L(k) k
F = J*L(k)
for p = 1:3
P = [10 20 30]';
fff=subs(F,J,P(p))
ss=symsum(fff,k,1,9)
end
The outputted answers are:
10*L(1) + 10*L(2) + 10*L(3) + 10*L(4) + 10*L(5) + 10*L(6) + 10*L(7) + 10*L(8) + 10*L(9)
20*L(1) + 20*L(2) + 20*L(3) + 20*L(4) + 20*L(5) + 20*L(6) + 20*L(7) + 20*L(8) + 20*L(9)
30*L(1) + 30*L(2) + 30*L(3) + 30*L(4) + 30*L(5) + 30*L(6) + 30*L(7) + 30*L(8) + 30*L(9)
Accepted Answer
More Answers (0)
Categories
Find more on Logical in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!