trying to make fourier transform of 3 pulses but the sampling is bad, how to fix it?

1 view (last 30 days)
when i try to make fourier transform of 3 pulses the resault doesn't look so good but when i make fourier transform of only one puls it's fine, please help. this is my code:
clear all
close all
clc
ts=0.001;
fs=1/ts;
x=-10:ts:10;
a=2;
y=rectangularPulse(-a/2,a/2,x)+rectangularPulse(6-a,6,x)+rectangularPulse(-6,-6+a,x);
figure;
subplot(1,2,1)
plot(x,y)
ylim([-1 2])
yf=fftshift(fft(y))/length(x);
f=linspace(-fs/2,fs/2,length(x));
subplot(1,2,2)
plot(f,abs(yf))
%xlim([-4 4])

Accepted Answer

David Goodmanson
David Goodmanson on 3 Jul 2017
Hi Kobi,
Thanks for posting solid code. For an fft, to make the frequency grid n times finer, the boundaries of the time record (tmax, tmin) have to be increased by a factor of n. What you have now is
ts=0.001; fs=1/ts; x=-10:ts:10; % 2e4+1 point fft
These particular pulses do not have to be described by anything as fine as ts = .001, so you could try, for example
ts=0.1; fs=1/ts; x=-100:ts:100; % 2e3+1 point fft
ts=0.01; fs=1/ts; x=-100:ts:100; % still 2e4+1 point fft
ts=0.001; fs=1/ts; x=-100:ts:100; % keep .001, 2e5+1 point fft
with in all cases
plot(f,abs(yf),'o-') % zoom in to see points per oscillation
Widening the time record by a factor of 10 cuts down the duty cycle of the pulse by that factor, so the frequency domain amplitude is down by 10 (but the shape has not changed). All three of the examples have the same finer frequency grid spacing, but they have progressively more extensive frequency grids.

More Answers (0)

Categories

Find more on Fourier Analysis and Filtering in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!