trying to make fourier transform of 3 pulses but the sampling is bad, how to fix it?
조회 수: 1 (최근 30일)
이전 댓글 표시
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])
댓글 수: 0
채택된 답변
David Goodmanson
2017년 7월 3일
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.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Spectral Measurements에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!