필터 지우기
필터 지우기

How to properly take fft in MATLAB plus take real and imaginary components?

조회 수: 15 (최근 30일)
L'O.G.
L'O.G. 2022년 3월 22일
댓글: KSSV 2022년 3월 22일
I wish to calculate the real and imaginary parts of the fft of a function f(t) that I can determine with arbitary time spacing. How do I do this, and how can I adjust the sampling frequency of the resulting fft? When I change dt for the time vector, I no longer sample that function as precisely, but then df for the fft (I think) is more finely spaced. I guess I am misunderstanding something. Also, when I take the absolute value to obtain the one-sided fft, I no longer have any imaginary component. I think I misunderstanding some basic aspects of the fft that I hope somebody can walk me through.
t = linspace(0.01,100,10000); % arbitrary time spacing here
nfft = 2^nextpow2(numel(t)); % not sure why this must be the case, but I've seen this in examples
dt = t(2) - t(1); % linear spacing
df = 1/dt;
Freq = (df/2)*linspace(0,1,nfft/2+1); % I guess df/2 is the Nyquist criterion as is the nfft/2 ?
f_w = abs(fft(f_t,nfft)); % Take one-sided of f_t
A = real(f_w);
B = imag(f_w); % doesn't return anything

답변 (2개)

KSSV
KSSV 2022년 3월 22일
You have used abs at the fft, how do you expect aa complex out put? You should not take abs if you want the complex output.
t = linspace(0.01,100,10000); % arbitrary time spacing here
nfft = 2^nextpow2(numel(t)); % not sure why this must be the case, but I've seen this in examples
dt = t(2) - t(1); % linear spacing
df = 1/dt;
Freq = (df/2)*linspace(0,1,nfft/2+1); % I guess df/2 is the Nyquist criterion as is the nfft/2 ?
f_w = fft(f_t,nfft); % Take one-sided of f_t
A = real(f_w);
B = imag(f_w); % doesn't return anything
  댓글 수: 2
L'O.G.
L'O.G. 2022년 3월 22일
Shouldn't I take the one-sided fft here? If so, how?
KSSV
KSSV 2022년 3월 22일
You may take the one-sided fft, but to have real and complex parts; you need not to do abs.

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


Walter Roberson
Walter Roberson 2022년 3월 22일
Arbitrary time values means your times might not be uniform intervals. You should use nufft
https://www.mathworks.com/help/matlab/ref/double.nufft.html
  댓글 수: 1
L'O.G.
L'O.G. 2022년 3월 22일
By arbitrary, I just meant that I can calculate the function f(t) with any time values that I want.

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

카테고리

Help CenterFile Exchange에서 Fourier Analysis and Filtering에 대해 자세히 알아보기

태그

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by