Fourier Transformation of dirac comb

37 views (last 30 days)
Johannes Siegel
Johannes Siegel on 22 Mar 2021
Edited: Paul on 23 Mar 2021
Hello guys,
in my code I generated a dirac comb and its FFT with:
%Time Signal
CarrierFrequenz=100; %frequency of the impulse in Hz
fs=CarrierFrequenz*10; % sample frequency (10 times higher than Carrier Frequency)
L=fs; %length signal
t=0:1/fs:1; % time vector
y=zeros(size(t));
y(1:fs/CarrierFrequenz:end)=1; %dirac comb
subplot(3,1,1)
plot(t,y); %time signal
xlabel('time(s)')
ylabel('P1')
%Frequency signal
Y = fft(y);
P2 = abs(Y/L);
subplot(2,1,2)
f = (fs*(-L/2:((L/2)-1))/L); %frequency domain
plot(f,P2(1:end-1))
title(' Amplitude Spectrum of S(t) FFT')
xlabel('f(Hz)')
ylabel('|P1(f)|')
and it generates the following plot:
Signal processing says:
So I wonder why the amplitudes in the frequency spectrum have this stair form and their magnitudes are way less than in the time domain.
Would be more than happy if s.o. could help me with that.
Best regards
Johannes

Accepted Answer

Paul
Paul on 22 Mar 2021
Edited: Paul on 23 Mar 2021
There is one too many points in the signal y. If you
plot([y y])
and zoom in you'll see the pulse at sample 1001 immediately followed by a pulse at sample 1002. So the underlying infinte length sequence isn't the infinite length sequnece in your question. But if you make y one sample shorter, then the underlying infinite sequence is the sequence in your question and it yields the expected result, at least with respect to eliminating the spreading (spectral leakaage) and non-constant peaks in the frequency domain. I didn't look carefully at the scaling.
CarrierFrequenz=100; %frequency of the impulse in Hz
fs=CarrierFrequenz*10; % sample frequency (10 times higher than Carrier Frequency)
L=fs; %length signal
t=0:1/fs:1; % time vector
t = t(1:end-1); % this line changed
y=zeros(size(t));
y(1:fs/CarrierFrequenz:end)=1; %dirac comb
subplot(3,1,1)
plot(t,y); %time signal
xlabel('time(s)')
ylabel('P1')
%Frequency signal
Y = fft(y);
P2 = abs(Y/L);
subplot(2,1,2)
f = (fs*(-L/2:((L/2)-1))/L); %frequency domain
plot(f,P2(1:end)) % this line changed
title(' Amplitude Spectrum of S(t) FFT')
xlabel('f(Hz)')
ylabel('|P1(f)|')
  2 Comments
Johannes Siegel
Johannes Siegel on 23 Mar 2021
Thank you very much. You helped me a lot!
Johannes Siegel
Johannes Siegel on 23 Mar 2021
Edited: Johannes Siegel on 23 Mar 2021
Probably you can help me with my another issue. I want to calculate the same in simulink. To generate the Dirac comb, I use a pulse generator and for the fft a spectrum analyzer. But I doesn't work like expected. Here's the link :

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!