필터 지우기
필터 지우기

How do you centre your plot at '0' on the X-axis after performing a Fourier transform?

조회 수: 19 (최근 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?

답변 (1개)

Dr. Seis
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
Matt
Matt 2012년 7월 16일
I have used abs(fftshift(fft(x))) but that just gives me my plot at the middle of all my values including the zero's. In your example you do not zero pad. I need to use many zero's in my case...
Lamda1 = .003;
N = pi./Lamda1;
Step1 = .03;
A4 = [-N/2:Step1:(N/2)-Step1];
R4 = zeros(size(A4));
R4 = (0.5 + (0.5)*((1 - (A4.^2)).^2));
R4 = 10*log10(R4);
A4 = asin(A4);
figure (10); plot(A4,R4)
FD4 = fft(R4, 200000) / N;
%figure (11); plot(abs(FD4));
figure (12); plot(abs(fftshift(FD4)))
Dr. Seis
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 CenterFile Exchange에서 Graphics Object Identification에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by