clc
clear

x = linspace(-pi, pi, 1000);

f = zeros(size(x));
f(x > 0 & x < pi) = 1;
f(x > -pi & x < 0) = -1;

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

figure;
plot(x, f, 'b', 'LineWidth', 1.5);
plot(x, F, 'Color', [0.85 0.33 0.10], 'LineWidth', 1.5);

title('Fourier Series Functions by "kaliyah johnson"');
xlabel('X');
ylabel('Functions');

Embed on website

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