# Converting real samples to IQ

I have real-valued samples of a signal at a negative frequency (was mixed with a cosine of a higher frequency than itself). I want to quadrature modulate it up from $$-\omega_c$$ to 0. There seem to be two ways to do it. Both seem to make sense. I've tried and plotted both and they seem to give very similar results, but I can't understand how these two could be equivalent. I'm worried that I could be overlooking something or that maybe I should prefer one to the other.

Method 1:

$$I[n]=LPF(x[n]\cos(\omega_ct))$$ (LPF is low pass filter)

$$Q[n]=LPF(x[n]\sin(\omega_ct))$$

Method 2:

$$I[n]=x[n]\cos(\omega_ct)$$

$$Q[n]=H^\ast(x[n])\sin(\omega_ct)$$ (where $$H^\ast(x)$$ is the complex conjugate of the hilbert transform of $$x$$)

Method 2 is implemented in Matlab in a single line, because hilbert(x) returns $$x+jH(x)$$, where $$H(x)$$ is the hilbert transform of $$x$$:

IQ = conj(hilbert(x))


Is there something I'm missing here? It seems these two cannot possibly be the same, but plotting the magnitude of the fourier transform shows them to be the same. Or maybe the magnitude is the same, but phase is different?

Also, I want to say thanks to the community here because I have had a lot of questions lately and I have had great answers on each one.

• " (where H∗(x) is the complex conjugate of the hilbert transform of x)": if x is real, H(x) is also real, so H*(x) = H(x). However see my more detailed answer Mar 3, 2023 at 22:31
• Good catch Dan. I made a mistake here. I meant the conjugate of x+jH(x), so x-jH(x), not x+jH*(x).
– Levi
Mar 5, 2023 at 0:05

Note the OP has mixed continuous time and discrete time formulations. My answer below is given with continuous time $$t$$ but can equally be applied to discrete time index $$n$$.

A real signal cannot contain only negative frequencies but will have a complex conjugate symmetric spectrum which means equal magnitude and opposite phase negative and positive frequency components. That said method 1 can work because of the low pass filter: to shift the negative frequency passband component to DC, we multiply it with a positive frequency only local oscillator, which is complex as $$e^{j\omega_c t}= \cos(\omega_c t)+ j\sin(\omega_c t)$$. This will shift the signal upward in frequency such that the negative frequency component is centered on DC (assuming it was at the frequency given by $$\pm \omega_c$$) and the positive frequency component will be shifted up to $$2\omega_c$$ and subsequently removed by the low pass filter.

Thus to do method 1 properly with $$x(t)$$ as the real Input we have:

$$x(t)e^{j\omega t}= x(t)\cos(\omega_c t)+ jx(t)\sin(\omega_c t)$$

Resulting in the real and imaginary components at the input to the low pass filters on each path.

The frequency spectrums showing the processing in Method 1 are depicted below:

Method 2 if done properly allows us to eliminate the low pass filtering. To be clear, the ‘Hilbert’ function returns the analytic signal as $$x(t)+ j\hat{x}(t)$$ which is a complex passband signal which only has positive frequency components. ($$\hat{x}(t)$$ is the Hilbert Transform of $$x(t)$$.) The waveform would still be at frequency $$\omega_c$$ but exist at the positive frequency component only (as a complex signal with I and Q paths). Thus we can move this signal down to baseband by multiplying with a complex LO given as $$e^{-j\omega_c t}$$, which would require four real multiplications (multiply out the complex input and complex LO as $$(I_1+jQ_1)(I_2+jQ_2)$$ to get implementation), but to note importantly that the spectrum would be mirrored from the method 1 given which moved the negative frequency component to baseband. This is of little consequence as the signal is the same just mirrored, and it is trivial to mirror the spectrum back by changing the sign of Q in the result, or alternatively change the sign of Q in the analytic signal that was returned by ‘Hilbert’ (which will then indeed be the negative frequency component), and multiply that result by $$e^{j\omega t}$$.

That said, the correct approach using method 2 would be:

$$(x(t)-j\hat{x}(t))(\cos(\omega_c t)+j\sin(\omega_c t))$$

Where the above terms are multiplied out to get the real and imaginary components for the output as $$I_o+jQ_o$$:

$$I_o(t) = x(t)\cos(\omega_c t) + \hat{x}(t)\sin(\omega_c t)$$ $$Q_o(t) = x(t) \sin(\omega_c t) - \hat{x}(t)\cos(\omega_c t)$$

The frequency spectrums showing the processing in Method 2 are depicted below:

With method 1 we only need two real multipliers but requires the additional low pass filters (may not be that bad to do for the case of a carrier significantly higher than the signal bandwidth along with high enough sampling rates to support the higher frequency component without aliasing), while with method 2 we require four real multipliers but eliminate the need for additional filtering.

As the OP pointed out to me in the comments, the filter complexity to do the low pass filter and Hilbert filter would be similar. That said the advantages of Method 2 is that we can filter once (real $$x(t)$$ with a real Hilbert filter, and if properly done such that the delay matched path is just an integer sample delay the processing is minimized to just one filter). This then requires four real multipliers for the like and cross terms as detailed above. Compared to method 1, the low pass filter would be of similar complexity, but we have to filter the real and imaginary legs of the complex product; the operations to do this would significantly offset the savings of just having two multipliers.

This is diagrammed below with the implementation for Method 1 where $$h(t)$$ represents the impulse response for the low pass filter:

Compared to that for Method 2, where here $$h(t)$$ is different but of similar complexity as the impulse response for the Hilbert Transform approximation:

Method 2 appears to be more complicated, but if the filter complexity was similar, Method 2 only requires half the filtering operations compared to Method 1. Below is an example plot showing how I would construct a discrete time Hilbert from a Half band filter by heterodyning the Halfband coefficients. We see from this that if the Halfband represented the required low pass filter for Method 1, the same filter complexity would be useful as the Hilbert for Method 2 (with a trivial integer sample delay for the delayed matched path).

That said, when the carrier frequency is similar to the bandwidth (where we have the upper sideband and lower sideband both in proximity to DC), Method 2 has a clear advantage in terms of lower overall processing required for a discrete-time implementation. However when the carrier is significantly higher than the bandwidth Method 1 has an advantage as even though a simpler bandpass Hilbert could be used for Method 2 in this case, the low pass filters for Method 1 can run at a lower sampling rate (more efficient decimating low pass filters can be used).

It may also be thought that for the case of discrete time processing, method 1 would require a higher sampling frequency, but this is not actually the case: both methods can operate with a Nyquist frequency just above the upper bandwidth of $$x(t)$$ with sufficient margin for filtering. If this were the case with method 1, the upper sideband would circularly rotate to be half in the positive frequency (straddling Nyquist) and half in the negative frequency, and the low pass filter would equivalently reject it.

• Thanks for the answer Dan. I made a mistake in my question, and had intended method 2 to be what you listed here. I feel like my original two questions still stand though: 1. Is there some reason I should prefer one to the other? It seems that they both accomplish the goal. 2. I'm wondering why these two are equivalent. It seems they cannot be comparing side by side: I[n] = LPF(x(t)cos(ωct)) vs I[n] = x(t)cos(ωct) So one is LPFed and the other is not, but the result appears identical. Similar for Q[n], different but the result appears the same.
– Levi
Mar 5, 2023 at 0:13
• @Levi I think I answered (1): it comes down to the complexity of the filter— for very tight bandwidths (when the carrier isn’t much higher than the bandwidth) implementing the required filter could be prohibitive. (2) I show with the spectrums by they are equivalent other than a possible gain scaling; they both properly move and isolate the negative spectrum to baseband. Was that not quite clear? Mar 5, 2023 at 0:18
• I reread your answer and I think I had the wrong comparison for #2. The comparison is really more like I[n] = h(t) convolved with x(t)cos(ωct) vs I[n] = x(t)cos(ωct)+H(x(t))sin(ωct).
– Levi
Mar 5, 2023 at 0:21
• Dan, if I am understanding you your point is that the room for the filter's transition band is equal to fc-B. Therefore, if fc is only slightly higher than B you must have a very high filter order which can be prohibitive. In that case, you prefer the Hilbert method. Doesn't the Hilbert also have a transition band? For #2, I see where I had gone wrong. I had been trying to understand how I(t)=h(t) convolved with x(t)cos(ωct)) in method 1 could be equal to I(t)=x(t)cos(ωct) in method 2, but in method 2 it is actually I(t)=x(t)cos(ωct)+H(x(t))sin(ωct).
– Levi
Mar 5, 2023 at 0:46
• Why is it with method 1 that we cannot shift by less than the BW? That would make sense to me for real modulation since the frequency spectrum becomes "split" into two images each with half power, but in the case of quadrature wouldn't the image also move?
– Levi
Mar 5, 2023 at 1:34

Okay, you have two different symbols, $$n$$ and $$t$$, representing the same thing. I am going to define $$t=nT$$ (where $$T$$ is the sampling period for $$x(t)$$ and $$x[n]\triangleq x(nT)$$ ).

Method 1: ($$\operatorname{LPF}\{\cdot\}$$ is a lowpass filter.)

$$I[n] = \operatorname{LPF} \big\{ x[n] \cos(\omega_c nT) \big\}$$

$$Q[n] = -\operatorname{LPF} \big\{ x[n] \sin(\omega_c nT) \big\}$$

Method 2: ($$\mathscr{H}\{\cdot\}$$ is the Hilbert transform.)

$$I[n] = x[n]\cos(\omega_c nT)$$

$$Q[n] = \mathscr{H} \big\{ x[n] \big\} \sin(\omega_c nT)$$

Am I representing the two methods accurately?

Then Method 1 is the same as:

$$I[n] + j Q[n] = \operatorname{LPF} \big\{ x[n] e^{-j\omega_c nT} \big\}$$

and Method 2 is, for positive frequencies, the same as:

$$I[n] + j Q[n] = \big( x[n] + j\mathscr{H} \big\{ x[n] \big\} \big) e^{j\omega_c nT}$$

I'm still wondering about that last statement, but I think it's true.

• Hilbert Transform of a real function is real, so complex conjugate is somewhat meaningless, no? Mar 3, 2023 at 22:33
• @DanBoschen i'm still mulling this question. i wonder if it's a misnomer for a simpler question. but i am still wondering about the meaning of the question. both are modulating up: they are shifting a spectrum to the right if $\omega_c T>0$. Mar 3, 2023 at 22:38
• Robert, I made a mistake in my original post. I did not intend to take the complex conjugate of the hilbert transform, but rather the complex conjugate of x[n]+jH(x[n]), so x[n]-jH(x[n]) which I believe should give the IQ data of the negative frequencies rather than the positive.
– Levi
Mar 5, 2023 at 0:17
• Okay @Levi we'll figger it out. There are some cross products in Method 2 that is bothering me at the moment. That's why I'm not done with your answer. I s'pose I should sit down with pen-and-paper, but what I thought was a simple frequency translation in Method 2 is a little more to it than I thought. Mar 5, 2023 at 0:23