I am trying to compare two datasets in MATLAB. To do this, I need to filter the data sets by Fourier transform of the data, filtering, and then the inverse Fourier transform.
When I invert the Fourier transform, the data, however, I get a burst at each end of the red data set (the image shows the first burst), it should be close to zero at the beginning, like a blue line. I compare many datasets, and this happens sometimes.
I have three questions about this phenomenon. Firstly, what could be the reason for this, secondly, how can I fix it, and thirdly, it will affect the data further in the time series or only at the beginning and end of the time series, as can be seen from the figure.
Any help would be greatly appreciated.

source share