how to scale fft?
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
hy guys.
i have a question concerning the scaling in fft .
i have seen alot of code on this forum, but some of the code scale the fft with length of the time domain while other's with increment.
code:
clear all; clc
dt=0.1;
t=-5:dt:5;
z=numel(t);
df = 1/dt;
f = linspace(-df/2, df/2, z);
h_t=rectpuls(t,1/f0);
h_f=fftshift(fft(h_t,n));
% how to scale h_f? should i divide h_f with z or dt and why?
% thank you in advance
채택된 답변
0 개 추천
The DFT is a tool for computing several other theoretical transforms. It can be used to compute a Discrete Fourier Series, which is when you would scale by the length. It can also be used to approximate a continuous Fourier transform, which is when you scale by the time increment.
There is also some disagreement across different professions (esp., engineering versus physics) on scaling factors in the definitions of these transforms. Therefore, the safest way to determine the scaling that you need is to just compare the formula in Matlab's FFT defintiion to the formula for the thing you want to compute.
댓글 수: 8
Rabih Sokhen
2022년 2월 10일
okay deal
thank you Matt.
Rabih Sokhen
2022년 2월 10일
one more question plz. my aim is continuous Fourier transform.
if i already have h_t and i want to scale h_f , should i multiply h_f with dt --> h_t=fftshift(fft(h_f)))*dt ?
and if i want to find h_t from h_f, should i divide h_t with dt --> h_t=fftshift(fft(h_f)))/dt ?
thank you in advance
Matt J
2022년 2월 10일
Yes.
Rabih Sokhen
2022년 2월 10일
thank you for your help
To illustrate ...
If the desire is to use fft() to compute the DFT to approximate the Continuous Time Fourier Transform (CTFT) of a finite duration signal, then zero padding should be considered because the DFT inherenntly assumes the underlying signal is the periodic extension of the seuqence, which can lead to misleading results.
Consider an example with a rectangular pulse and its CTFT
syms t
f(t) = rectangularPulse(0,1,t);
syms w
ctft(w) = fourier(f(t),t,w); % CTFT of f(t)
Samples of f(t) at 20 Hz
dt = 0.05;
tvec = 0:dt:1;
fvals = ones(1,numel(tvec));
Compute the Discrete Time Fourier Transform (DTFT) of fvals.
[dtft,wdtft] = freqz(fvals,1,1024);
Plot the CTFT and the DTFT. We see that dt*DTFT is a reasonable approximation to the CTFT up to the Nyquist frequency (pi/dt)
figure
fplot(abs(ctft),[0 65]);
hold on
plot(wdtft/dt,dt*abs(dtft))
xlim([-1 pi/dt])
legend('CTFT','DTFT')

Now add to the plot the DFT of fvals
figure
fplot(abs(ctft),[0 65]);
hold on
plot(wdtft/dt,dt*abs(dtft))
dft = fft(fvals);
wdft = (0:numel(dft)-1)/numel(dft)*2*pi/dt;
stem(wdft(1:11),dt*abs(dft(1:11)),'MarkerFaceColor','auto')
xlim([-1 pi/dt])
legend('CTFT','DTFT','DFT no pad')

The DFT is nonzero only at w = 0 because the periodic extension of fvals is a constant sequence over all time. Note that the DFT are samples of the of the DTFT as they must be.
Now take the DFT with zero padding to pick up the ups and downs of the DTFT.
figure
fplot(abs(ctft),[0 65]);
hold on
plot(wdtft/dt,dt*abs(dtft))
dft = fft(fvals,64);
wdft = (0:numel(dft)-1)/numel(dft)*2*pi/dt;
stem(wdft(1:31),dt*abs(dft(1:31)),'MarkerFaceColor','auto')
xlim([-1 pi/dt])
legend('CTFT','DTFT','DFT w/pad')

In summary for a finite duration signal, the DFT of time domain samples of the signal are frequency domain samples of the DTFT, and dt*DTFT is an approximation to the CTFT up to the Nyquist frequency.
Edit: I just realized that making the samples of the rectangular pulse unity at the leading and trailing edges is is why the DTFT is larger at DC and has nulls offset in frequency compared to the CTFT. I guess one has to decide how what it means to sample at the discotinuities. I think reasonable options are to use a sample equal to 1 at the leading edge and zero at the trailing edge, i.e., the sampling starts at t = 0+, or make the samples = 1/2 at both edges. Here's the final plot using the second approach
figure
fplot(abs(ctft),[0 65]);
hold on
fvals = [0.5 ones(1,numel(tvec)-2) 0.5];
[dtft,wdtft] = freqz(fvals,1,1024);
plot(wdtft/dt,dt*abs(dtft));
dft = fft(fvals,64);
wdft = (0:numel(dft)-1)/numel(dft)*2*pi/dt;
stem(wdft(1:31),dt*abs(dft(1:31)),'MarkerFaceColor','auto')
xlim([-1 pi/dt])
legend('CTFT','DTFT','DFT w/pad')

Rabih Sokhen
2022년 2월 11일
Thank you Paul for your response, i understand more now.
in my case i want to do the fft of a vector so it will fit my continuous function.
just to be sure, the best way is to multiply my fft with dt instead of pading?
thank you in advance.
Matt J
2022년 2월 11일
No, you must always multiply by dt. The issue of choosing how much zero-padding you need to do is separate.
Rabih Sokhen
2022년 3월 3일
thank you Matt, sry for the late response .
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Install Products에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
