How do I put a summation equation in matlab?
204 views (last 30 days)
Show older comments
Hi people, I need to plot the graph of f(x)= -4*(pi)^2 + the summation from n=1 (sin(n*x)*(-1)^n) / n for different values of n. I am fine plotting the graphs but I cant get the summation to work. Can anyone help?
0 Comments
Answers (3)
Star Strider
on 11 Feb 2016
I’m not certain about the summation you want to do, but the cumsum function is likely worth considering.
One possibility:
x = 0.5; % Scalar ‘x’
n = 1:10;
f = -4*(pi)^2 + cumsum( (sin(n*x).*(-1).^n) ./ n);
figure(1)
plot(n, f)
grid
0 Comments
Sam Sherman
on 17 Feb 2022
SSEQ = (symsum(((deflectiontest)-(yq.^(2))) .^ (1 ./ 2),x,1,n)) ./ (n);
2 Comments
Walter Roberson
on 18 Feb 2022
The first parameter of the symsum is the expression to be summed. The second parameter is the variable of summation. The expression looks to be independent of the variable of summation, so it looks like the result would be the first parameter times the span of the third to fourth parameter, so (n-1)+1 = n
See Also
Categories
Find more on Spline Postprocessing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!