MATLAB: Plot a fourier series representation of function

fourier seriesMATLAB

Best Answer

Check this code
t = linspace( -pi , pi );
y1 = zeros(size(t));
for i = 1:2:5
y1 = y1 + (4/pi)*(sin(i*t)/i);
end
y2 = zeros(size(t));
for j= 1:2:39
y2 = y2 + (4/pi)*(sin(j*t)/j);
end
subplot(2,1,1)
plot(t, y1)
subplot(2,1,2)
plot(t, y2)
Related Question