how to plot a summation function in matlab using a for loop
8 views (last 30 days)
Show older comments
how can i plot this summation function using a for loop?

i start write this:
t = -pi : pi/6 : pi;
s=0;
for i = 0:1
s=s+(2/3)*(pi^2) + ((-1)^i)* (-4*cos(i*t))/i^2
0 Comments
Accepted Answer
Rik
on 28 May 2023
It's a good start.
You should only put the summation part in the loop, and you should store the results in a vector. (remember that the first element of a vector is index 1)
I would also suggest that you use n instead of i.
If you need help implementing this, feel free to post a comment.
4 Comments
Rik
on 28 May 2023
I understand it may be difficult to ignore the spammer, but feel free to follow up with a comment.
See Also
Categories
Find more on Annotations 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!