How do you centre your plot at '0' on the X-axis after performing a Fourier transform?
9 ビュー (過去 30 日間)
古いコメントを表示
I have a generated signal which I perform an fft on as well as zero-padding it with 5000 zeros. The problem I have is that the resulting plot is centered at 2500 (i.e. half of 5000).
Is it possible for me to shift my plot 2500 spaces to left on my X-axis so that the plot is centered on 0?
0 件のコメント
回答 (1 件)
Dr. Seis
2012 年 7 月 16 日
編集済み: Dr. Seis
2012 年 7 月 16 日
fftshift might be what you are looking for. Does this example help?
dt = 0.1; % Fs = 1/dt;
N = 16;
t = (0:N-1)*dt;
g = randn(size(t));
Nyq = 1/2/dt;
df = 1/N/dt;
f = -Nyq : df : Nyq-df;
G = fftshift(fft(g));
figure; plot(f,G);
[EDIT]
f1 = -3; % minimum frequency
f2 = 3; % maximum frequency
idx = f1 < f & f < f2;
figure; plot(f(idx), G(idx));
2 件のコメント
Dr. Seis
2012 年 7 月 16 日
編集済み: Dr. Seis
2012 年 7 月 16 日
Why not specify a range using logicals... continuing my example above:
f1 = -3; % minimum frequency
f2 = 3; % maximum frequency
idx = f1 < f & f < f2;
figure; plot(f(idx), G(idx));
Note: Your "N" will be based on the number you pad up to (i.e., 200000) for determining what "f" is for your data.
参考
カテゴリ
Help Center および File Exchange で Title についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!