N = 15;
n = 0:N;
A = 1;
dt = 0.01;
t = (-2:dt:2)';
T = 1;

%

an = -(4 * (-1).^n * abs(A)) ./ (pi * (4 * n.^2 - 1))

%

wn = 2 * n * pi / T

%

y = an(1) / 2 + sum(an(2:end) .* cos(wn(2:end) .* t), 2)

%

plot(t, y)