How do you centre your plot at '0' on the X-axis after performing a Fourier transform?
조회 수: 31 (최근 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.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!