Product inside summation in Matlab
8 views (last 30 days)
Show older comments
Hi, I am trying to code the below series in Matlab. To simplify, I am using a and b here, but essentially they are elemets of vectors.
I wrote it as:
I am not sure how to deal with the product inside the addition. Could anyone help me with how to code this? (a and b are not symbols so symprod would probably not work)
0 Comments
Answers (2)
Torsten
on 23 Feb 2022
Edited: Torsten
on 23 Feb 2022
For infinite vectors (a)_j and (b)_j and oo replaced by Kmax
t = 2;
Kmax = 50;
prod1 = a(t+1:Kmax).^(t+2:Kmax+1);
B = b(t+1:Kmax).^(t+1:Kmax);
prod2 = cumprod(B);
summands = prod1.*prod2;
expr = a(t)^(t+1) + sum(summands)
2 Comments
Torsten
on 23 Feb 2022
All in one line:
expr = a(t)^(t+1) + sum(a(t+1:Kmax).^(t+2:Kmax+1).*cumprod(b(t+1:Kmax).^(t+1:Kmax)))
See Also
Categories
Find more on Assumptions 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!