Pulse Train FFT low resolution

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 个评论

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.

请先登录,再进行评论。

 采纳的回答

Akira Agata
Akira Agata 2017-12-2
编辑:Akira Agata 2017-12-2

1 个投票

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 个评论

Thank you for amazing advice. How Can adjust sampling frequency to match 2^N. And how you tell my NFFT should be 7000 ? So you say NFFT should be equal to signal lenght ??
Oh I understood. So I should make samples in order to have signal lenght of 2^N.
Now mine is 7000 which is less than 2^13 so I will make it exactly 2^13.
> And how you tell my NFFT should be 7000 ?
In your original script, the size of the array y was 1x7101. And sample number in one cycle of your pulse train was 1000. So, I choose 7000 as a NFFT.
> How Can adjust sampling frequency to match 2^N
I've just tried to make a simple example, as follows. I hope it will be your help somehow !
% 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 pulses
t = 0:(1/fs):tw-(1/fs);
d = 0:(tw/10):t(end)+(1/fs);
y = pulstran(t,d,'rectpuls',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])
Thank very much for your valuable time. There is an issue here actually. I want to see the sinc form.
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])
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.

请先登录,再进行评论。

更多回答(0 个)

标签

Community Treasure Hunt

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

Start Hunting!

Translated by