t=linspace(0,12,1000);T=2;Y=g(t)';f=0;N=50;hold on;h=zeros(N,1);clr=lines(N);for n=1:25:N; line(t,Y,'linewidth',5) grid on;hold on; A=(1/T)*quadgk(@g,0,T); P=@(t)g(t).*(cos(n*pi*t)); Q=@(t)g(t).*(sin(n*pi*t)); Ax=(2/T)*quadgk(P,0,T); Bx=(2/T)*quadgk(Q,0,T); f=f+(Ax*cos(pi*n*t)+Bx*sin(pi*n*t)); final=A+f; h(n)=plot(t,final,'linewidth',2,'Color',clr(n,:));end hold off;legend(h, num2str((1:N)','harmonic-%d')).I wish to plot different graphs for every iteration done. Is it poosible?
MATLAB: How to plot different graphs for each iteration of a for loop
for loopfourier seriesMATLAB
Best Answer