필터 지우기
필터 지우기

How to plot properly a 2d fft of data?

조회 수: 19 (최근 30일)
mm99
mm99 2020년 1월 4일
댓글: Star Strider 2020년 1월 5일
Hi!
Ive generated a wave in a numerical model using a chirp signal and collected the responses of the model in chosen points. How can I plot properly the 2d fft of this data. The responses are in attached mat.
Here is the chirp signal:
t2=0:dt:(2e-4)-dt;
signal2 = chirp(t2,0,9.99900000000000e-05,1e6,'linear');
Is the attached image correct?
thanks in advance

채택된 답변

Star Strider
Star Strider 2020년 1월 4일
Not entirely. The posted image is the plot of the two-sided Fourier transform after using the fftshift function. The result is that the frequency axis is not correct. (Note that a 2D fft (fft2) is usually applied to images and similarly-constructed matrices. The 1D fft is correct here.)
Try this:
D = load('matlab.mat');
mat = D.mat;
t = 0:numel(mat)-1; % Time Vector (Units: Time Units)
Ts = mean(diff(t)); % Sampling Time Interval
Fs = 1/Ts; % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
L = numel(t); % Signal Length
FTmat = fft(mat)/L; % Fourier Transform
Fv1 = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector - One-Sided Fourier Transform (Units: Cycles/Time Unit)
Iv = 1:numel(Fv1); % Index Vector
figure
plot(Fv1, abs(FTmat(Iv))*2)
grid
title('One-sided Fourier Transform')
xlabel('Frequency')
ylabel('Amplitude')
Fv2 = linspace(-Fn, +Fn, L); % Frequency Vector - Two-Sided Fourier Transform (Units: Cycles/Time Unit)
figure
plot(Fv2, fftshift(abs(FTmat)))
grid
title('Two-Sided Fourier Transform')
xlabel('Frequency')
ylabel('Amplitude')
producing:
1How to plot properly a 2d fft of data - 2020 01 04.png
  댓글 수: 6
mm99
mm99 2020년 1월 5일
Thank you for such detailed information!
Star Strider
Star Strider 2020년 1월 5일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spectral Measurements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by