# Bandpass function in Matlab inverting the Frequency spectrum when using a hermitic transformed signal

I have a VNA response (S11 parameters) from 3.5 to 40 GHz. Then I apply a hermitic transformation (complex conjugate) to it since we only have the spectrum for the positive frequencies. Then I use the IFFT to know the time domain representation. Then I would like to apply a Bandpass Filter to clean the time domain signal and avoid aliasing by using the bandpass function of Matlab. The problem comes when the function shows that the original signal's spectrum is inverted. Why does this happen? Thank you!

• What exactly do you mean by "hermitic transformation"? How do you know the spectrum is inverted? It'd be useful if you could show your code.
– MBaz
Feb 3, 2023 at 16:25

The process is correct, except the Hermitian half of the spectrum (assuming a causal Real time domain signal) needs to be placed AFTER the positive frequency spectrum. The DFT is given as:

$$X(k) = \sum_{n=0}^{N-1}x[n]W_n^{nk}$$

(Where $$W_n^{nk} = e^{-j2\pi n k}$$)

And the FFT is an algorithm that efficiently returns the $$N$$ samples of $$X(k)$$ for $$k$$ from $$0$$ to $$N-1$$, given n samples of the time domain waveform $$x[n]$$, and with this all the "negative frequency" portion of the spectrum is ordered after the "positive frequency" portion as depicted in the following graphic:

If the Hermitian negative frequency half for the assumed causal real time domain signal is placed first, this would explain the inverted spectrum the OP is seeing.

Further, any filtering of the time domain waveform after processing with the IFFT will not eliminate the time domain aliasing that has already occurred. To reduce the effects of time domain aliasing, the time duration of the original waveform capture can be increased to beyond the impulse response time of the system for which the frequency response was measured. Observe the tails of the time response as it approaches the center of the result to confirm that they are sufficiently reduced. Large time responses near $$N/2$$ for an N-pt IDFT suggest time domain aliasing is occurring. An additional test would be to confirm the resulting time response is sufficiently similar after further doubling the time duration (assuming the waveform under test is stationary for the test duration).

Note that in general we can have large time responses near $$N/2$$ without any time domain aliasing occurring (for example, if the time domain waveform is actually truncated). But this would not be the case when measuring a typical system where the impulse response is expected to decay smoothly in time. As a demonstration of this and further insight into effects and manifestation of time domain aliasing, consider the example in the plot below:

Here I have created the resulting inverse DFT's directly in the time domain. What is shown is a truncated Sinc function as well as the Dirichlet Kernel (which is an aliased Sinc function). The plot shows it in time as it would be ordered in an inverse DFT: The first half of the plot represents positive time, and the second half of the plot represents negative time for a non-causal waveform centered on time at 0. In this case, the result in frequency would be real and therefore the time response itself will be Hermitian Symmetric.

The main point of observation is the Sinc as shown if not truncated would continue with it's peaks going down at a rate proportional to $$1/n$$. Everything shown in the first half of the time domain response is exactly that as given for a Sinc, so there is no time domain aliasing causing a distortion of those sample values. In contrast is the time domain plot for the Dirichlet Kernel, which is an aliased Sinc function. We are seeing the elevated values in the middle of the plot due to the increase from time domain aliasing of a Sinc function that wasn't truncated and continued past that time alias location of half the index and above. This is time domain aliasing and its effect in the time domain. To reduce this given the same Sinc waveform, we need to increase the overall time duration so that the Sinc continues to decrease in relative magnitude before it reaches the time alias location of half the index and above.

I then took the FFT of these waveforms, with symmetric zero padding to interpolate more samples on the Discrete Time Fourier Transform (DTFT). What we see are two distortions in frequency as compared to what we would expect for a perfect Sinc function with no distortion in the time domain. A perfect Sinc in time would be a brickwall function in frequency, which we see the DTFT has approximated. The Truncated Sinc has ripple in the passband and stopband due to the effects of truncation in the time domain alone (with truncation, I mean that we have multiplied our perfect time domain Sinc with a rectangular time domain window; we set all values above n=250 to 0). There is no truncation with the Dirichlet Kernel, it is all time domain aliasing of all values of the Sinc above n=250. We see that the distortion due to time domain aliasing is significantly worst in both the passband and stopband than the distortion due to time domain truncation.

If you are already familiar with the important requirement to have an anti-alias filter prior to sampling a signal with an A/D converter (ADC), then this provides further insight into how the distortion due to time domain aliasing is irreparable once it has occurred (without further knowledge of the waveform). In the case of sampling the first Nyquist zone (DC to $$f_s/2$$) with an ADC, we must sample at high enough frequency to ensure there is insignificant energy in the frequency domain outside of the Nyquist bandwidth from DC to $$f_s/2$$, and for that we would typically provide an anti-alias filter that precedes the sampling operation- otherwise frequency domain aliasing will occur. The same concept applies here except in this case we are saying that we must sample at a high enough time duration to ensure there is insignificant energy in the time domain outside of the duration from $$t=0$$ to half the total time duration of the capture. With a network analyzer measurement, we do not have the ability put the equivalent of a filter on the frequency domain waveform (convolution in the frequency domain) prior to that waveform being sampled, and as is the case with the ADC, once sampled in any given sample we do not know what component of that sample is the actual waveform or energy from aliasing- unrecoverable distortion. What we can possibly do however is increase the total time duration of the capture, which is the equivalent of increasing the sampling rate for the case of sampling with an ADC to reduce aliasing.

• Thank you very much for your extensive response, I will try to apply what you say and let you know. Feb 13, 2023 at 14:13