Pulse Train FFT low resolution

2 views (last 30 days)
Ata Sarrafi
Ata Sarrafi on 2 Dec 2017
Commented: Ata Sarrafi on 4 Dec 2017
Hi,
I have written a code for pulse train and its FFT. However, my FFT resolution is bad. How can I make this better ?
fs=1e9 ; %sampling frequency
t=-0.1e-6:1/fs:7e-6; %time base
T=1e-6; %Period
D=0.5e-6 %Duration
N=40; %Number of pulses
d=[0:T:T*N];
y=pulstran(t,d,'rectpuls',D);
t=t+0.25e-6;
subplot(2,1,1)
plot(t,y);
title(['Rectangular Pulse width=', num2str(T),'s']);
xlabel('Time(s)');
ylabel('Amplitude');
L=length(y);
NFFT = 1024;
X = fftshift(fft(y,NFFT)); %FFT with FFTshift for both negative & positive frequencies
f = fs*(-NFFT/2:NFFT/2-1)/NFFT; %Frequency Vector
subplot(2,1,2)
plot(f,abs(X)/(L),'r');
title('Magnitude of FFT');
xlabel('Frequency (Hz)')
ylabel('Magnitude |X(f)|');
  1 Comment
Ata Sarrafi
Ata Sarrafi on 3 Dec 2017
it does not work
f
s=1.17e9 ; %sampling frequency
t=0:1/fs:7e-6; %time base
T=1e-6; %Period
D=0.5e-6 %Duration
N=80; %Number of pulses
d=[-70e-6:T:T*N];
y=pulstran(t,d,'rectpuls',D);
t=t+0.25e-6;
subplot(2,1,1)
plot(t,y);
title(['Rectangular Pulse width=', num2str(T),'s']);
xlabel('Time(s)');
ylabel('Amplitude');
L=length(y);
NFFT = 8192;
X = fftshift(fft(y,NFFT)); %FFT with FFTshift for both negative & positive frequencies
f = fs*(-NFFT/2:NFFT/2-1)/NFFT; %Frequency Vector
subplot(2,1,2)
plot(f,abs(X)/(L),'r');
title('Magnitude of FFT');
xlabel('Frequency (Hz)')
ylabel('Magnitude |X(f)|');
my length is 8191 and I set NFFT=8192=2^13 resolution now is even worth.

Sign in to comment.

Accepted Answer

Akira Agata
Akira Agata on 2 Dec 2017
Edited: Akira Agata on 2 Dec 2017
When using FFT, you should consider about "periodic boundary condition." In your original code, I don't think this condition was satisfied.
If my understanding is correct, your waveform in time domain repeats every 1000 samples. And if you want to obtain more frequency resolution, you should increase FFT length. So, based on your original code, you should change "NFFT = 7000;"
To enhance the performance, I would recommend adjusting sampling frequency to match the FFT length (NFFT) to 2^N.
  5 Comments
Akira Agata
Akira Agata on 4 Dec 2017
OK. The sinc function in frequency domain is a Fourier transform of singe rectangle pulse. The following is an example.
To understand the relationship between rectangular pulse train and sinc function in detail, please refer to a textbook of digital communication theory.
% Fixed parameters
T = 1e-6; %Period
D = 0.5e-6; %Duration
N = 10; %Number of pulses
tw = T*N; % Time window
% Adjust fs to make Nfft = 2^14
Nfft = 2^13;
fs = Nfft/tw; % Sampling frequency
% Generate single pulse
t = -(tw/2):(1/fs):(tw/2)-(1/fs);
y = rectpuls(t,D);
% FFT
X = fftshift(fft(y));
f = fs*(-Nfft/2:Nfft/2-1)/Nfft; %Frequency Vector
% Show the result
figure
subplot(2,1,1)
plot(t,y)
title(['Rectangular Pulse width = ', num2str(D),' [s]'])
xlabel('Time [s]')
ylabel('Amplitude')
subplot(2,1,2)
plot(f,abs(X)/Nfft,'r')
title('Magnitude of FFT')
xlabel('Frequency (Hz)')
ylabel('Magnitude |X(f)|')
xlim([-30e6 30e6])
Ata Sarrafi
Ata Sarrafi on 4 Dec 2017
Thank you but I already know this and plotted this FFT before. I am not checking only 1 pulse. As I mentioned before I want to observe it for pulse train not only 1 pulse. It is going to be sinc as well.

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!