If the maximum magnitude M = A^2 + B^2 of DFT transform corresponds to the frequency F,
(A – real, B – imaginary output of DFT, at frequency F)
then is it correct to do the following:
for (j = 0; j < size; ++j) {
data[j] -= (A*cos(2*PI*F*j/dfts) -
B*sin(2*PI*F*j/dfts)) / dfts;
}
In order to cancel (subtract) that frequency influence from original wave data?
The data is assumed to be a sum of several sines and cosines with different frequencies and multiplied by different coeffitients.
EDIT1:
I could achieve the cancelation by subtracting, and the result is correct. There was a mistake in above, but it is possible to do it. If interested I can post the way of doing it.
EDIT2:
And if you do the next DFT transform, you will get a very small, near zero value at the A and B values.
But you need to remember, that the original data can be the sum of 4 frequencies (sines and cosines) but the DFT transform will give you as much as the size of DFT is divided by 2.
No – that won’t work. It could only work if the time domain component matched the FFT bin frequency exactly and the phase of the component is constant throughout the sample window, and even if this were the case you’d still need to take care of phase in your subtraction.
Ideally you need to remove (i.e. zero) the component in the frequency domain and then do an inverse FFT. Note that you probably don’t want to just zero the bin of interest in the frequency domain, as this will produce artefacts in the time domain after you inverse FFT – you’ll need to apply a window function to the bin of interest and adjacent bins.