4

Given a signal g(t) <--> G(f), a time-compression g(at) <--> 1/(abs(a)) * G(f/abs(a)), but not with the FFT as I've found out. Performing the FFT on g(a*t) doesn't scale the amplitude of the G(f/abs(a)) spectrum at all. What gives?

Fs=100;
t=-5:1/Fs:5;
y=sin(2*pi*t);

a=4;
g=sin(2*pi*a*t);

m = length(y);
n = pow2(nextpow2(m));
Y = fftshift(fft(y,n));
G = fftshift(fft(g,n));

f0 = (-n/2:n/2-1)*(Fs/n);

figure;
plot(f0, abs(Y)/Fs);

figure;
plot(f0, abs(G)/Fs);

Here's y:

Original spectrum of y

Here's g. It's at 4 Hz, but the amplitude is basically the same as y when it should be 25%. Also, why does the y-axis go up to 5 and not 1? I scaled the abs(fft(y)) and abs(fft(g)) by Fs so shouldn't the max amplitude be 1? Time compressed spectrum of g

user50420
  • 81
  • 6

1 Answers1

5

You have 4 times as many cycles in the time -5:ts:5. If your y and g signals had the same number of cycles and different frequencies, then the expected result would have appeared I believe. In short, g is not time compressed version of y as we can verify by simply counting the number of cycles in each signal.

Time domain comparing time compressed signal and higher frequency signal

time domain signal

higher frequency signal has more cycles that time compressed version.

Code comparing time compression and just a higher frequency


fs = 100;

time = -5:1/fs:5;

y = sin(2*pi*time);

time2 = -5/4 : 1/fs : 5/4;
g = sin(2*pi*4*time2);


h = sin(2*pi*4*time);

f1 = linspace(0, fs, length(time));
f2 = linspace(0, fs, length(time2));

plot(f1, abs( fft(y) )/fs, '.-');
hold on;
plot(f2, abs( fft(g) )/fs, '.-');
plot(f1, abs( fft(h) )/fs, '.-');

legend('original', 'time compressed', 'higher frequency');

grid on;
xlim([0 10]);

Result

spectrum of time compressed

AJN
  • 3,756
  • 1
  • 9
  • 20
  • Thanks for your reply, but I'm not sure I follow. What should I do differently in the MATLAB to produce the expected result? – user50420 Oct 04 '20 at 14:29
  • 1
    @user50420 I wanted to show that the code in your question doesn't time compress the original signal. It creates a new signal having more cycles than the original. It is **not** the time compressed version of the original signal. I have also added a code which I think is the correct way for time compression. It seems to give expected (?) results. – AJN Oct 04 '20 at 14:40
  • Ok, I figured that since they were both plotted over the same time interval that they were the same signal, but I suppose they should have the same number of cycles instead. – user50420 Oct 04 '20 at 14:46
  • Yes. Imagine if it was a non periodic signal which was being time compressed. We would have expected time compression to preserve the number of peaks and valleys and not introduce new ones. – AJN Oct 04 '20 at 14:47