I am trying to plot a partial sum n=1,2,3 and 10 using for loop function and then plot all the partial sums in one graph.
Below is the code I wrote but somehow it keep giving me error at n==2.
Also how do i plot them in one graph?
x=-pi:0.01:pi;sum=0;for n=1:10 sum=sum+(pi+(-2/n*cos(n*pi)*sin(n*t))); if n==1 plot(x,sum) Elseif n==2 plot(t,sum) Elseif n==3 plot(t,sum) Elseif n==10 plot(t,sum) endend
Best Answer