You’re not calculating the fft but the analytic Fourier transform. To do this, use the definition of the Fourier transform of x(t):
X(w) = int(x(t) * exp(j*w*t), t, T1, T2)
defining w=2*pi*f.
Specifically, with the Symbolic Math Toolbox:
syms E T t w
S1 = int(4*E/T*t * exp(j*w*t), t, 0, T/4);
S2 = int(E * exp(j*w*t), t, T/4, T/2);
S3 = int(-E * exp(j*w*t), t, T/2, 3*T/4);
S4 = int(4*E/T*(t-T) * exp(j*w*t), t, 3*T/4, T);
X(w) = S1 + S2 + S3 + S4;
X(w) = simplify(collect(X(w)))
X(w) = simplify(collect(rewrite(X(w), 'sincos')))
X(w) =
-(4*E - 4*E*exp(T*w*1i) - 4*E*exp((T*w*1i)/4) + 4*E*exp((T*w*3i)/4) + E*T*w*exp((T*w*1i)/2)*2i - E*T*w*exp((T*w*3i)/2)*1i + E*T*w*exp((T*w*3i)/4)*1i)/(T*w^2)
X(w) =
((E*T*cos((3*T*w)/2)*1i + 2*E*T*sin((T*w)/2) - E*T*sin((3*T*w)/2) + E*T*sin((3*T*w)/4) - E*T*cos((3*T*w)/4)*1i - E*T*cos((T*w)/2)*2i)*w + 4*E*cos(T*w) - 4*E + 4*E*cos((T*w)/4) - 4*E*cos((3*T*w)/4) + E*sin(T*w)*4i + E*sin((T*w)/4)*4i - E*sin((3*T*w)/4)*4i)/(T*w^2)
Best Answer