0
$\begingroup$

I have a signal,

fs = 100;                                % Sample frequency (Hz)
t = 0:1/fs:10-1/fs;                      % 10 sec sample
x = (1.3)*sin(2*pi*15*t)                 % 15 Hz component
+ (1.7)*sin(2*pi*40*(t-2)) ;             % 40 Hz component

when I take fft of x then its amplitude and phase spectrum are:

enter image description here

enter image description here

And now if deliberately I will put the leading 10 values to zeros

x(1:10) = 0;

then as per my understanding the frequency of the complete data set is not changed so the fft would not be changed. Which is supported by the amplitude fft response.

FFT amplitude response after making leading values zero

But the phase plot is showing some strange result.

enter image description here

Can some help me why the response is changed. Although they both are following the same equation. Also If I have a equation cos(2*pift) and my t is from 3:Tp and before time =3sec the response is zero, then will it not have the same response as t:0:Tp.

$\endgroup$
  • 2
    $\begingroup$ Why do you think frequency of signal was not changed? You change signal -> spectrum is changed too. Hint - plot signal in time domain before and after. Think. If it will not be any idea -> change signal with x(1:49)=0 or x(1:98)=0. $\endgroup$ – SergV May 4 '15 at 16:00
  • $\begingroup$ As per my understanding the FFT try to map the sinosoidal signal in the provided data range by following the data variations. So in the case I have mentioned, I thought The data set is now shrinked so it will only effect the frequency resolution but the frequency specturm amplitude will remain the same. I also tried x(1:49)=0 or x(1:98)=0 and the spectrum (max location is same). Thats why I was thinking that the frequency response should remain same (with some distortion in resolution) $\endgroup$ – Mr. Khan May 4 '15 at 16:23
  • $\begingroup$ Try x(1:500)=0, x(1:990)=0. See not only spectrum, but plot(t,x). Your signal is not 2-sinusoidal now. $\endgroup$ – SergV May 4 '15 at 17:14
  • $\begingroup$ Dear I have tried x(1:500) and also till x(1:900) to zeros. But again the amplitude response of FFT is same (meaning peaks at the same frequency) but with distortions due to the less number of samples. Also this shows that the main frequency contents are the same as the original one. Your comment on this behavior is highly appreciated. $\endgroup$ – Mr. Khan May 6 '15 at 9:34
0
$\begingroup$

I expand and modify your code:

N = 100;  %number of sample
fs = 100; % Sample frequency (Hz)
t = 0:1/fs:(N-1)/fs;                    
x = sin(2*pi*10*t);  % 10 Hz component
%x(:)=1;    
f = 0:fs/N:(N-1)*fs/N;    

subplot(2,2,1);
plot(t,x);
title('full signal'); grid on;
subplot(2,2,3);
plot(f(1:N/2),abs(fft(x)(1:N/2)));
title('spectrum'); grid on;

x1=x;     %x1 - zero pad signal
x1(1:ceil(N/3))=0;
x1(ceil(2*N/3):N)=0;

subplot(2,2,2);
plot(t,x1,'b',t,x1,'*');
title('zero pad signal'); grid on;
subplot(2,2,4);
plot(f(1:ceil(N/2)),abs(fft(x1)(1:ceil(N/2))));
title('spectrum'); grid on;

enter image description here

You can see signals before and after zero padding are quite different. And the spectrums are quite different too. There is strong part of signal x1 with frequency 10 Hz, and you can see strong peak on spectrum.

You can uncomment line with x(:)=1; First full signal will be DC (constant), second (zero padding) - rectangle. Quite different signals and quite different spectrum.

UPDATE
About phase spectrum. Update to code:

F=fft(x);
angle(F(11))  % phase = -1.5708
F1=fft(x1);
angle(F1(11)) % phase =  -1.6018

Phase for x makes sense only for bin with non zero amplitude. Non zero amplitude numbers are 11 and 91. Phase for any other index are results of calculations errors of FFT function.
As x1 has big part of x the phase spectrum for this bins has approximately the same value (as you can see).

Hint. You can present x1 as product of $sin$ function and rectangle function. So spectrum of x1 is a convolution of spectrum $sin$ and rectangle.

$\endgroup$
  • $\begingroup$ I think your answer elaborate the concept efficiently. I am accepting the answer for your elaboration. But My other small part of question is why the spectrum (phase also) changes by tampering the data set at the first positions. $\endgroup$ – Mr. Khan May 7 '15 at 9:43
  • $\begingroup$ @Mr.Khan, I update my answer $\endgroup$ – SergV May 7 '15 at 10:26
  • $\begingroup$ Thanks alot , Now I understood that the phase of the frequency spectrum remains approx unchanged. I was also guessing that but once again it was a nice ellaboration. $\endgroup$ – Mr. Khan May 7 '15 at 11:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.