FFT of a frequency sweep using logarithmic spacing.
Hello,
I’ve been trying to obtain the FFT of a frequnecy sweep performed using a logarithmic progression. The signal was generated using a waveform generator, but is similar to that obtained using the chirp function as in the example below.
% Define parameters
Fs = 10000; % Sampling frequency (Hz)
T = 1/Fs; % Sampling period
L = Fs*2; % Length of signal
t = (0:L-1)*T; % Time vector
% Generate frequency sweep signal
f1 = 1; % Start frequency (Hz)
f2 = 2000; % End frequency (Hz)
y = 0.5*chirp(t, f1, T*L, f2, ‘logarithmic’);
% Calculate FFT
Y = fft(y);
% Calculate the frequency axis
f = Fs*(0:(L/2))/L;
% Normalize the FFT result by the amplitude of the original signal
P2 = abs(Y/L);
P1_arb = P2(1:L/2+1);
P1_arb(2:end-1) = 2*P1_arb(2:end-1);
% Plot signal and FFT
figure;
subplot(1, 2, 1)
plot(t, y)
title(‘Generated Signal’)
xlabel(‘Time (s)’);
ylabel(‘Amplitude (V)’);
subplot(1, 2, 2)
plot(f, P1_arb);
title(‘Log Chirp’);
xlabel(‘Frequency (Hz)’);
ylabel(‘|Y(f)|’);
When plotting the signal it’s clear that the amplitude is 0.5. However, the FFT shows a variable amplitude which is nowhere close to the value of 0.5 expected.
If instead the chirp function is set to ‘linear’ the result is a constant amplitude across the frequency range but the amplitude is 0.008, which I don’t understand how it is related to the inital value of 0.5.
y = 0.5*chirp(t, f1, T*L, f2, ‘linear’);
% Calculate FFT
Y = fft(y);
% Calculate the frequency axis
f = Fs*(0:(L/2))/L;
% Normalize the FFT result by the amplitude of the original signal
P2 = abs(Y/L);
P1_arb = P2(1:L/2+1);
P1_arb(2:end-1) = 2*P1_arb(2:end-1);
% Plot signal and FFT
figure;
subplot(1, 2, 1)
plot(t, y)
title(‘Generated Signal’)
xlabel(‘Time (s)’);
ylabel(‘Amplitude (V)’);
subplot(1, 2, 2)
plot(f, P1_arb);
title(‘Linear Chirp’);
xlabel(‘Frequency (Hz)’);
ylabel(‘|Y(f)|’);
Could you help me normalize the resulting FFT in order to obtain the expected amplitude.
Thank you,
NunoHello,
I’ve been trying to obtain the FFT of a frequnecy sweep performed using a logarithmic progression. The signal was generated using a waveform generator, but is similar to that obtained using the chirp function as in the example below.
% Define parameters
Fs = 10000; % Sampling frequency (Hz)
T = 1/Fs; % Sampling period
L = Fs*2; % Length of signal
t = (0:L-1)*T; % Time vector
% Generate frequency sweep signal
f1 = 1; % Start frequency (Hz)
f2 = 2000; % End frequency (Hz)
y = 0.5*chirp(t, f1, T*L, f2, ‘logarithmic’);
% Calculate FFT
Y = fft(y);
% Calculate the frequency axis
f = Fs*(0:(L/2))/L;
% Normalize the FFT result by the amplitude of the original signal
P2 = abs(Y/L);
P1_arb = P2(1:L/2+1);
P1_arb(2:end-1) = 2*P1_arb(2:end-1);
% Plot signal and FFT
figure;
subplot(1, 2, 1)
plot(t, y)
title(‘Generated Signal’)
xlabel(‘Time (s)’);
ylabel(‘Amplitude (V)’);
subplot(1, 2, 2)
plot(f, P1_arb);
title(‘Log Chirp’);
xlabel(‘Frequency (Hz)’);
ylabel(‘|Y(f)|’);
When plotting the signal it’s clear that the amplitude is 0.5. However, the FFT shows a variable amplitude which is nowhere close to the value of 0.5 expected.
If instead the chirp function is set to ‘linear’ the result is a constant amplitude across the frequency range but the amplitude is 0.008, which I don’t understand how it is related to the inital value of 0.5.
y = 0.5*chirp(t, f1, T*L, f2, ‘linear’);
% Calculate FFT
Y = fft(y);
% Calculate the frequency axis
f = Fs*(0:(L/2))/L;
% Normalize the FFT result by the amplitude of the original signal
P2 = abs(Y/L);
P1_arb = P2(1:L/2+1);
P1_arb(2:end-1) = 2*P1_arb(2:end-1);
% Plot signal and FFT
figure;
subplot(1, 2, 1)
plot(t, y)
title(‘Generated Signal’)
xlabel(‘Time (s)’);
ylabel(‘Amplitude (V)’);
subplot(1, 2, 2)
plot(f, P1_arb);
title(‘Linear Chirp’);
xlabel(‘Frequency (Hz)’);
ylabel(‘|Y(f)|’);
Could you help me normalize the resulting FFT in order to obtain the expected amplitude.
Thank you,
Nuno Hello,
I’ve been trying to obtain the FFT of a frequnecy sweep performed using a logarithmic progression. The signal was generated using a waveform generator, but is similar to that obtained using the chirp function as in the example below.
% Define parameters
Fs = 10000; % Sampling frequency (Hz)
T = 1/Fs; % Sampling period
L = Fs*2; % Length of signal
t = (0:L-1)*T; % Time vector
% Generate frequency sweep signal
f1 = 1; % Start frequency (Hz)
f2 = 2000; % End frequency (Hz)
y = 0.5*chirp(t, f1, T*L, f2, ‘logarithmic’);
% Calculate FFT
Y = fft(y);
% Calculate the frequency axis
f = Fs*(0:(L/2))/L;
% Normalize the FFT result by the amplitude of the original signal
P2 = abs(Y/L);
P1_arb = P2(1:L/2+1);
P1_arb(2:end-1) = 2*P1_arb(2:end-1);
% Plot signal and FFT
figure;
subplot(1, 2, 1)
plot(t, y)
title(‘Generated Signal’)
xlabel(‘Time (s)’);
ylabel(‘Amplitude (V)’);
subplot(1, 2, 2)
plot(f, P1_arb);
title(‘Log Chirp’);
xlabel(‘Frequency (Hz)’);
ylabel(‘|Y(f)|’);
When plotting the signal it’s clear that the amplitude is 0.5. However, the FFT shows a variable amplitude which is nowhere close to the value of 0.5 expected.
If instead the chirp function is set to ‘linear’ the result is a constant amplitude across the frequency range but the amplitude is 0.008, which I don’t understand how it is related to the inital value of 0.5.
y = 0.5*chirp(t, f1, T*L, f2, ‘linear’);
% Calculate FFT
Y = fft(y);
% Calculate the frequency axis
f = Fs*(0:(L/2))/L;
% Normalize the FFT result by the amplitude of the original signal
P2 = abs(Y/L);
P1_arb = P2(1:L/2+1);
P1_arb(2:end-1) = 2*P1_arb(2:end-1);
% Plot signal and FFT
figure;
subplot(1, 2, 1)
plot(t, y)
title(‘Generated Signal’)
xlabel(‘Time (s)’);
ylabel(‘Amplitude (V)’);
subplot(1, 2, 2)
plot(f, P1_arb);
title(‘Linear Chirp’);
xlabel(‘Frequency (Hz)’);
ylabel(‘|Y(f)|’);
Could you help me normalize the resulting FFT in order to obtain the expected amplitude.
Thank you,
Nuno fft, frequency sweep, signal processing MATLAB Answers — New Questions