![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/463270/image.png)
How to make a serie ?
8 views (last 30 days)
Show older comments
Yamina chbak
on 16 Dec 2020
Edited: Yamina chbak
on 18 Dec 2020
Hi, i need to write a sum of serie :
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/462900/image.png)
for m=1:20
syms k u
b(k)=(k+1)^2-k^2;
F=symsum((b(k)-b(k+1))*u(:,m-k),k,1,m-1)
end
F
but i get error
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/462905/image.png)
Necessary I need u(:,m-k)
Please help me
0 Comments
Accepted Answer
Walter Roberson
on 16 Dec 2020
It is never possible to use a symbolic variable as an index in MATLAB.
You need to create a definite list of values and sum() the list. Or loop adding on to a total.
Note by the way that
and so b(k) - b(k+1) = (2*k+1) - (2*(k+1)+1) = -2
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/463270/image.png)
5 Comments
Walter Roberson
on 17 Dec 2020
Sorry, you are changing equations too much. Your equation here is quite different than your equation in your Question, and it is not really reasonable to answer both at the same time as they are too different. What is the question you need answered?
Note: using U(:,m-k) is not equivalent to
as t is obviously a vector of values that as outside observers we need to assume is a real number in ℝ or possibly even in ℂ and cannot assume that t just happens to be linear indices . At the very least it is likely that t starts from 0,
and so is not suitable for indexing. Indeed, since
then k can equal m, and then
would be 0, and that is not a valid matrix index.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/463520/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/463525/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/463530/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/463535/image.png)
More Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!