clc
clear

x =  (-pi: pi: 1000);

f = ones(size(x));
f(x < 0) = -1;

F = (4/pi) * (sin(x) + sin(3*x)/3 + sin(5*x)/5 + sin(7*x)/7);

plot(x, f, 'LineWidth', 1.5)
hold on
plot(x, F, 'LineWidth', 1.5)
hold off

grid on
xlabel('x')
ylabel('Functions')
title('Fourier Series Functions by Kimberly Randle')
legend('f(x)', 'Fourier Series')

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: