How does the FFT zero pad
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
I am using the Hilbert function for an analysis, and I would like to use the FFT method to get the imaginary part. What I am unsure of is how the FFT function is zero padding? I would like there to be an even number of zeros on each end of my data so that when I apply a window, my data are centered. Any help on this would be greatly appreciated.
example of code I'm using (i've attached an example mat file with the variable "prox")
a= hilbert(hann(length(prox)).*prox,2^8);
채택된 답변
Y = fft(X,n);
is the same as
Xp=X;
Xp(length(X)+1:n)=0;
Y=fft(Xp);
댓글 수: 8
Avelino Amado
2019년 5월 23일
Matt,
Thank you for your response. From what I'm gathering, is the fft function only zero pads the ends, and not the beginning? So if I want symmetrical padding, I would have to do it manually?
Yes, and you would also have to incorporate ifftshift, like in the following.
Xp=ifftshift( [zeros(p,1) ; X(:) ; zeros(p,1)] );
Y=fft(Xp);
Avelino Amado
2019년 5월 23일
Thank you for this quick responses. I'm not really understanding the difference between ifftshift and fftshift. If possible, could you help me understand the difference? Once again, thank you for your assistance
They are simply inverses of one another. ifftshift is what you use if your signal origin is sampled in the center of the input array, X. In this example, the original continuous signal, before sampling, had value 4 at t=0.
X =
0 0 0 0 1 2 3 4 3 2 1 0 0 0 0
By applying ifftshift, the samples are circulantly shifted so that the t-origin is sampled at the beginning of the array, which is where fft() expects it to be.
>> ifftshift(X)
ans =
4 3 2 1 0 0 0 0 0 0 0 0 1 2 3
If we now feed this to fft(), the output spectrum will also have its origin (the frequency origin) at the beginning of the array
>> fft(ifftshift(X))
ans =
Columns 1 through 10
16.0000 12.7758 5.9786 1.0000 0.0783 1.0000 1.0000 0.1673 0.1673 1.0000
Columns 11 through 15
1.0000 0.0783 1.0000 5.9786 12.7758
But this is often not how we like to look at things, so fftshift can be used to shift the origin to the center of the array again,
>> fftshift(ans)
ans =
Columns 1 through 10
0.1673 1.0000 1.0000 0.0783 1.0000 5.9786 12.7758 16.0000 12.7758 5.9786
Columns 11 through 15
1.0000 0.0783 1.0000 1.0000 0.1673
Avelino Amado
2019년 5월 23일
If I want to apply a window to my data the following be my order of operations
1) a= [zeros(p,1) ; X(:) ; zeros(p,1)]
2) b= ifft(hann(length(a).*a))
I guess my ultimate goal is to make sure my data are centered when I apply the window, because I've been trying different windows out and I think they are capturing incorrect part of my data because the fft function was only padding the end. This exchange has been very helpful
Matt J
2019년 5월 23일
This exchange has been very helpful
Does that mean you got it working? If so, please Accept-click the answer.
Avelino Amado
2019년 5월 23일
I have done the fft, ifftshift, but what I'm still unsure of is when I apply a window. My understanding would be I would window after I pad with zeros, is that correct?
Matt J
2019년 5월 23일
That is something that only you can know (because it is your algorithm). But ifftshift would normally be done right before fft.
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Transforms에 대해 자세히 알아보기
참고 항목
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)
