How to load an indexed vector into a symsum?

12 views (last 30 days)
I would like to load specific values into the symsum of each step, however it seems like i can't use the index of the sum as an index in my vector.
alpha=[1:100]; %example
syms D t
S1=symsum(alpha(n)*exp(-D*alpha(n)*t),n,1,100);
Error using sym/subsindex (line 836)
Invalid indexing or function
definition. Indexing must follow
MATLAB indexing. Function arguments
must be symbolic variables, and
function body must be sym
expression.
I understand that Matlab see n as a symbol and the cant use it in the alpha(n) vector. How can i circumvent this bump?

Accepted Answer

Birdman
Birdman on 25 Jan 2018
Edited: Birdman on 25 Jan 2018
Try this:
alpha=1:100;
syms D t n
S1=symsum(alpha.*exp(-D.*alpha.*t),n,1,100);
  2 Comments
Andreas Pedersen
Andreas Pedersen on 25 Jan 2018
Edited: Andreas Pedersen on 25 Jan 2018
Ahhh ofc course - use the matrix multiplikation, as long as length of alpha is the same as the length of the sum!
Birdman
Birdman on 25 Jan 2018
Yes, little tricks about symbolic toolbox :)
If the answer helped, can you accept it?

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!