Why does this Fourier series give lower amplitude for max value of signal?
The formula for the Fourier series is

$$x(t)=\sum_{k=-\infty}^{\infty}c_ke^{jk\omega_0 t}\tag{1}$$

You only use the non-negative indices $k$, but you must also use the negative ones. Since your signal $x(t)$ is real-valued, you can in fact compute everything using only the positive indices, but then you must take two times the real part:

$$x(t)=c_0+2\Re\left\{\sum_{k=1}^{\infty}c_ke^{jk\omega_0 t}\right\}\tag{2}$$

Note that you must add the DC term $c_0$ separately.

This is the corresponding Matlab code:


t=-10:0.001:10;
x_t = 0;
T = 10;
w0 = 2*pi/T;
numOfTerms = 100;


for k=1:numOfTerms-1
   a_k = (1/(w0*i*k*T))*(  exp(-1*i*k*w0)-exp(-3*i*k*w0)+ exp(-7*i*k*w0)- exp(-9*i*k*w0));
   x_t = x_t + a_k * exp(i*k*w0*t);
end

x_t = 2*real(x_t) + 2/5;

plot(t,x_t);