This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Differences between Matlab ifft and arm_cfft_f32

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:

real from arm_cfftreal from Matlabimag from arm_cfftimag from Matlab
-0.0731-0.073100
0.0779-0.077900
0.06720.067200
0.0124-0.012400
0.00660.006600
-0.19640.196400
0.06610.066100
0.0976-0.097600
-0.0497-0.049700
0.0457-0.045700

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.

Parents
  • 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.

Reply
  • 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.

Children