Hello, I'm writing an application where I get the output of the IFFT operation, using the arm_cfft_f32 function from CMSIS-DSP library like this:
arm_cfft_f32(&arm_cfft_sR_f32_len128, out_ifft, 1, 1);
where out_ifft is a 128*2 element vector with Hermitian symmetry because I need a real output.
I prepare the same vector and I use it again in Matlab to check the results:
salidamod=ifft(ifftshift(vector,2),NFFT);
The ifftshift function swaps the left and right halves of the vector,and it's necessary due to the requirements of the Matlab ifft function. I get this results:
Only the even samples are wrong, and only reversed...It's strange and I don't know why it happens. Could someone explain me the reason, please?
Thank you in advance.
My guess would be that something isn't quite right with your Matlab code. In particular, if you are incorrectly using ifftshift then it will end up modulating your time domain signal by (-1)^n which corresponds precisely to the sign differences that you are seeing.
If you are suspecting that the discrepancy is in the execution of cfft or ifft, first check the indices (sample numbers) of the data in the table you posted. Since the FFT/IFFT samples are numbered starting from zero it's possible that the rows with dissimilar results are from the odd samples. With k as the index, it seems like the samples got multiplied by
j^(2k), with the erroneous entries being odd samples
or
j^(2(k+1)), with the erroneous entries being even samples
as they traversed the IFFT algorithm.
However, the source of your problem is more likely in the improper use of ifftshift. As you mentioned
"I prepare the same vector and I use it again in Matlab to check the results"
Why not try to do the swapping yourself and omit ifftshift in your MATLAB code first. This will help you verify if your interpretation of ifftshift is correct or the rest of your code is properly working. You may want to use a smaller number of samples first, maybe 64 or 32. You may also want to put ifftshift and ifft into two lines first.
Well, this did not explain the reason you are seeking but I hope it will help you troubleshoot the problem.
I think that it's something inside the algorithm because I get the correct output in both cases when I use the inverse functions (FFT) I assume that it could be the possible answer...
Do you mean you performed a (forward) FFT on the values you tabulated and you recovered your original frequency samples (those that exhibited Hermitian symmetry) both in CMSIS-DSP library and MATLAB?
Some members also encountered problems regarding forward and inverse FFT:
the first one is very similar to yours, the second is about forward FFT.
Yes, exactly. The first case you've showed is similar than mine, but I don't use the Real IFFT, I use the Complex IFFT but I get a real signal at the output because the input has Hermitian Simmetry.
As the receiver in both cases can get the correct values I think that the problem isn't so important. Although, thank you everyone for your help
OK.