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!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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)
