MATLAB: How to calculate sum of power series

sum of power

i cant get the code the work
im trying to write a(n+2)=(a(n+1)a(n+1)-b*a*n-2)/(n+2)(n+1)
but the variable a and b are tripping me up
and this error keep coming up
Error: Invalid expression. When calling a function or
indexing a variable, use parentheses. Otherwise, check
for mismatched delimiters.
n=5;
for i=1:n
p=(((a*n+1*a*n+1-b*a*n-2)/(n+2*n+1);
end

Best Answer

n=5;
a = rand ;
b = rand ;
p = 0 ;
for i=1:n
p=p+ (a*n+1*a*n+1-b*a*n-2)/(n+2*n+1); % check the expression though
end
Related Question