MATLAB: How to make a serie

MATLABsumsum function

Hi, i need to write a sum of serie :
with b_k= (k+1)^2-(k)^2 and u^(m-k) is the numerical solution approximation u(x,t_m-k) for k=1,…m-1 and m=1,….,20
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
Necessary I need u(:,m-k)
Please help me

Best Answer

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