IFFT on symmetric spectral data giving complex result?

10 ビュー (過去 30 日間)
Christian Taylor
Christian Taylor 2024 年 11 月 11 日
コメント済み: Bruno Luong 2024 年 11 月 11 日
I have a single sided frequency spectrum which I am attempting to convert into a real time domain signal using the matlab IFFT function. I understand that I need to ensure the spectrum is complex conjugate symmetric in order for the output of the IFFT function to be purely real, however that doesn't seem to have worked and I can't see what I'm doing wrong. The relevant code I'm using is as follows:
twoSidedSpectrum = [singleSpectrum(1:end); flipud(conj(singleSpectrum(2:end)));
timeSignal = ifft(twoSidedSpectrum);
Note that singleSpectrum is odd in length, therefore twoSidedSpectrum is odd in length also. I would have though this would produce a purely real ifft output?

採用された回答

Bruno Luong
Bruno Luong 2024 年 11 月 11 日
編集済み: Bruno Luong 2024 年 11 月 11 日
assert(isreal(singleSpectrum(1)), 'first element must be real');
twoSidedSpectrum = [singleSpectrum(1:end); flipud(conj(singleSpectrum(2:end)));
timeSignal = ifft(twoSidedSpectrum);
  6 件のコメント
Paul
Paul 2024 年 11 月 11 日
Bruno's comment with implicit zero padding seems to be faster than my comment with explicit zero padding.
I wonder if that's because ifft is smart enough to realize that it does not need to fully construct the full vector in the implicit case for the particular X and NFFT input.
rng(100);
N = 1e7;
X = [rand; rand(N,1)+1j*rand(N,1)]; % odd case
f1 = @() ifft([X;zeros(N,1)],'symmetric'); % explicit
f2 = @() ifft(X,2*numel(X)-1,'symmetric'); % implicit
isequal(f1(),f2())
ans = logical
1
timeit(f1)
ans = 1.1295
timeit(f2)
ans = 0.8026
Bruno Luong
Bruno Luong 2024 年 11 月 11 日
I wonder if that's because ifft is smart enough to realize that it does not need to fully construct the full vector in the implicit case for the particular X and NFFT input
It must be the case. Whenn I interface FFTW they have all such options and more. Matlab uses tthe same library.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSpectral Measurements についてさらに検索

製品


リリース

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by