MATLAB: Convert Time Domain Signal Data into Frequency Domain, How to handle the imaginary terms

time domain & frequency domain

Hi Everyone,
I'm a beginner of MATLAB. I'm having some problems of converting time domain signal into frequency domain.
In time domain, is this the way to plot the graph?
value = [42007935 111212895 184546560 238219725 238219725 184546560 111212895 42007935]; time = [0, 1, 2, 3, 4, 5, 6, 7, 8 ]; plot (time, value);
Then, when i want to plot it in frequency domain, i use the following codes:
fft_Conv = fft (value); plot (time, fft_Conv);
I get a warning: Warning: Imaginary parts of complex X and/or Y arguments ignored.
Could anyone guide me how to plot signal in time domain and frequency domain?
Regards, HJ.C

Best Answer

You want to plot the magnitude and phase separately for the complex-valued data. Think of the polar form of a complex number. A few other things: you want to create a frequency vector to use in plotting the frequency domain data (DFT). You may or may not want to center 0 frequency in your Fourier transform, I do this below. Because the mean of your time data is so large, you are going to get a large 0 frequency magnitude in your Fourier transform.
value = [42007935 111212895 184546560 238219725 238219725 184546560 111212895 42007935];
time = 0:7;
stem(time,value,'markerfacecolor',[0 0 1])
title('Time Data'); xlabel('Time'); ylabel('Amplitude');
dftvalue = fft(value);
freq = -pi:(2*pi)/length(value):pi-(2*pi)/length(value);
figure;
stem(freq,abs(fftshift(dftvalue)),'markerfacecolor',[0 0 1])
title('Magnitude of DFT'); xlabel('Frequency'); ylabel('Magnitude');
figure;
stem(freq,angle(fftshift(dftvalue)),'markerfacecolor',[0 0 1])
title('Phase of DFT');
xlabel('Frequency'); ylabel('Magnitude');
% or stem(freq,unwrap(angle(dftvalue)),'markerfacecolor',[0 0 1])