Created
August 30, 2018 13:30
-
-
Save bencholmes/a5b85f75dd903d033463a1ba8a1dfdad to your computer and use it in GitHub Desktop.
A MATLAB function to force symmetry on an FFT, thus producing a real signal after an IFFT.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function X = forceFFTSymmetry(X) | |
% forceFFTSymmetry A function to force conjugate symmetry on an FFT such that when an | |
% IFFT is performed the result is a real signal. | |
% The function has been written to replace MATLAB's ifft(X,'symmetric'), as this function | |
% is not compatible with MATLAB Coder. | |
% Licensed under Creative Commons Zero (CC0) so use freely. | |
XStartFlipped = fliplr(X(2:floor(end/2))); | |
X(ceil(end/2)+2:end) = real(XStartFlipped) - sqrt(complex(-1))*imag(XStartFlipped); | |
% Or | |
% X(ceil(end/2)+2:end) = conj(XStartFlipped); | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment