4
\$\begingroup\$

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

\$\endgroup\$
1
  • \$\begingroup\$ Please plot both signals. You will get the answer immediately. \$\endgroup\$
    – AJN
    Oct 4 '20 at 14:21
5
\$\begingroup\$

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

\$\endgroup\$
4
  • \$\begingroup\$ Thanks for your reply, but I'm not sure I follow. What should I do differently in the MATLAB to produce the expected result? \$\endgroup\$
    – user50420
    Oct 4 '20 at 14:29
  • 1
    \$\begingroup\$ @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. \$\endgroup\$
    – AJN
    Oct 4 '20 at 14:40
  • \$\begingroup\$ 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. \$\endgroup\$
    – user50420
    Oct 4 '20 at 14:46
  • \$\begingroup\$ 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. \$\endgroup\$
    – AJN
    Oct 4 '20 at 14:47

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.