Your sin(x) term is constant in n, so you can move it outside the summation.
x = -pi:0.01:pi;
sx = sin(x);
factor = cumsum(2./(1:7))
result = factor .* sx.';
plot(x, result)
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!