I have a complex time varying signal at a single frequency x = a + jb
where a
represents the contribution from the cosine basis function and b
represents the contribution from the sinusoid basis function.
I am trying to understand how the output differs if I was to take a complex FFT of x
and inspect the real and imaginary components compared to taking two FFTs of the real and imaginary parts separately. I naively expected these to be equal when a=b. What am I missing?
% signal parameters
fs = 1e3;
f0 = 50;
t = (0:999)/fs;
wt = 0.5; %weighting between cosine and sin basis functions
NFFT = 1024;
freq = linspace(-fs/2,fs/2, NFFT);
freq2 = linspace(0,fs/2, NFFT/2);
wnd = hanning(length(t)).';
% Complex signal
x = wt*cos(2*pi*f0.*t) + (1-wt)*1j*sin(2*pi*f0.*t);
% 1 - Take FFT of complex signal and split into re/im components
X = fft(x.*wnd, NFFT);
Xre = abs(X(1:NFFT/2));
Xim = abs(fliplr(X(NFFT/2+1:end)));
% 2 - Split the signal into Re/Im and compute FFTs
Yre = abs(fft(real(x).*wnd, NFFT));
Yim = abs(fft(imag(x).*wnd, NFFT));
close all;
figure;
ax(1)=subplot(221);
plot(freq2, Xre, 'b');
legend('Cmplx Re');
ax(2)=subplot(222);
plot(freq2, Yre(1:NFFT/2), 'r');
legend('Split Re');
ax(3)=subplot(223);
plot(freq2, Xim, 'b');
legend('Cmplx Im');
ax(4)=subplot(224);
plot(freq2, Yim(1:NFFT/2), 'r');
legend('Split Im');
linkaxes(ax,'xy');
figure;
plot(freq, fftshift(abs(X)));