MATLAB: Sawtooth wave, using complex fourier transform find first 7 harmonic

complex form of fourier transformharmonicsawtooth wavewithout phases

There is a sawtooth wave with period T=1s and equation x(t)=t in the interval 0<=t<=T . Using the complex form of fourier transform , define the real amplitudes of the first 7 harmonic, without finding the phases. Could anyone help me do this in matlab ?

Best Answer

N = 512;
u = linspace(0,1,N+1);
U = fft(u(1:end-1))'/N;
U_0_7 = U(1:8);
U_0_7(2:end) = U_0_7(2:end)*2;
U_0_7 = [abs(U_0_7), angle(U_0_7)];
Related Question