how can I have a perfect rect function as the result of applying fft on sinc function?

조회 수: 16 (최근 30일)
I have to generate a perfect rectangle as the fft result of the sinc function. I am working with different parameters to achieve this, so far I could generate a good rectangle but it still has some imperfections. I want exactly a rectangle like what we have in theory. I attached my code and results to this message. Two problems that I have in this rect function:
1- spikes in the edges
2- gliteches along with the rect function
clear all;
Fs=2000; % sampling frequency
Ts=1/Fs; % sampling period
t=-1:Ts:1;
N=numel(t); % numel recommended instead of length
f=500;
cx=sinc(t*f);
cx(end-300:end)=0; cx(1:300)=0;
figure;
plot(t,cx);title("sinc function");
xlabel('time');
ylabel(' magnitude');
fy=(fft(cx));
Nyq = Fs/2; % Nyquist frequency is 1/2 of the sampling frequency
% dx = (t(end)-t(1))/(N-1); % Time increment, should rename to dt, but not used
% suggest not using colon with df stride, stick colon with unit stride
if mod(N,2) == 0 % N is even
k = ( (-N/2) : ((N-2)/2) )/N*Fs;
else % N is odd
k = ( (-(N-1)/2) : ((N-1)/2) )/N*Fs;
end
figure;
plot(k,fftshift(abs(fy*Ts)));title("rect function");
xlabel(' frequency t^{-1}');
ylabel(' magnitude');
xlim([-2000 2000])

답변 (1개)

Matt J
Matt J 2022년 6월 27일
편집: Matt J 2022년 6월 28일
I want exactly a rectangle like what we have in theory.
The FFT of a sinc function is not a perfect rect, even in theory. The continuous Fourier Transform of a continuous and infinitely long sinc function is a perfect rect.
The only way you can get a perfect discretized rect as the output of the fft is to start with the ifft of a perfect rect.
  댓글 수: 4
2NOR_Kh
2NOR_Kh 2022년 6월 30일
Thank you, Paul, it was a thoughtful solution. I searched these few days to see how I can even make that rect function close to a perfect rect, and also not by starting from a rect function and its ifft. I increased the period and somehow the result seems good, but I should use advanced ring removal techniques to make it better.
Paul
Paul 2022년 7월 1일
To be clear, I wasn't offerering a solution, If anything, I was illustrating that a solution doesn't exist.
In summary:
CT sinc -> CTFT -> rect
DT sinc -> DTFT -> periodic extension of rect
DT sinc -> DFT -> can't be done because DFT only applies for finite duration signals, and sinc is infinite duration
DF (discrete frequency) rect -> IDFT -> something close sinc*rect

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Discrete Fourier and Cosine Transforms에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by