# How do I modulate complex time domain signal to a carrier frequency?

I want to modulate a complex time domain signal to a carrier frequency 1880MHz but the sampling frequency is 30M which is smaller than Fs. I did upconversion using

exp(1i*2*pi*Fc*(0:length(signal)/Fs))

but the PSD isn't centered at Fc. I need to plot PSD and find the relation between the centered freq and the target Fc.

• @PeterK : edit window with lots of TeX becomes incredibly slow as for every single letter being pressed it re-renders all the typesetting from beginning to end. Hiding the preview does not help either. It makes editing quite painful with the mobile. All I need is a mode or button to enable/disable TeX rendering. With this auto rendering it takes hours! to edit a post especially towards the end of the page. Is it me only having this problem? (the mobile device has Celeron processor) but I use it %99 of the time...Is there a solution that I'm missing? This is DSP this is math intensive hence TeX – Fat32 Jun 21 '17 at 13:39
• hm, don't know whether that works on smart phones, but on my laptop/desktop firefox, right-click on formula, "Math Settings"->"Math Renderer"->"Plain Source" does it for me, @Fat32. – Marcus Müller Jun 22 '17 at 19:19
• That's it! I can't believe that I missed it! I remember having played with those settings once upon a time, but it seems I totally forgot about it somehow! Quite many thanks @MarcusMüller! Let me upvode one of your answers :))) – Fat32 Jun 22 '17 at 22:14
• @Fat32 haha, nah, don't need to reward me with internet points :) keep up the good work here instead – Marcus Müller Jun 22 '17 at 22:20

It is not clear why you would want to do this, and perhaps you are trying to achieve something at a bigger picture level where this is the wrong approach. However to clear up your question:

Since your sampling frequency is 30MHz, your unique digital spectrum is only from 0 to 30 MHz (or -15MHz to +15MHz depending on which portion of the spectrum you want to take). The rest of the spectrum, out to 1880MHz and beyond is replicas of this spectrum stated above.

1880 MHz/30MHz is 62.6666... so the boundary at 30*62 = 1860 MHz is identical to what exists at 0, and then from there up to 1860 + 30 MHz = 1890 MHz is identical to what exists at 30 MHz. So I suspect from your approach above that the result was a frequency at 1880-1860 = 20 MHz, which is identical to the frequency at 1880 MHz!

This is because the following frequencies are all aliases of the same when the sampling rate is 30 MHz:

20 MHz, 20+30*1=50 MHz, 20+30*2 = 80 MHz, 20+30*3 = 110 MHz .... all the way to 1880 MHz, which is 20 + 30*62.

The following post on the unique span for any digital spectrum may help to further clarify this result:

https://stackoverflow.com/questions/44429592/what-is-the-result-inside-fft-bin-at-different-index/44434979#44434979

UPDATE: From the comment you said that you "want to see multiple signals at the same frequencies on the same spectrum". And I assume your spectrum is centered at 1880 MHz, and you may be simulating a multicarrier system in the 1850 MHz to 1910 MHz band (my guess) such as CA_2-4 or PCS. Assuming that is the case, then your maximum bandwidth of the signal you want to simulate is 60 MHz, and to simulate that I would recommend simulating using complex signals at a sampling rate of 100 MHz (greater than 2x the single-sided BW of 30 MHz to appease Nyquist with additional room for evaluating effects beyond the band such as spectral regrowth or simulating filtering there, etc). In this case 1880 MHz can just as easily be represented at DC, and another signal at 1181.25 MHz (for example) can be placed at 1.25 MHz in your simulation. Why? Because the items of concern for us with regards to the carrier is the complex envelope of the carrier only; with regards to anything in our system simulation, we don't really care about the actual high frequency cycle rate of the carrier itself- only the magnitude and phase of the envelope versus time.

Alternatively, if you want to simulate with a real carrier, this is easily achievable too by centering the real signal at $F_s/4$ (where $F_s$ is your sampling rate) in your digital frequency span. The frequency span needed to simulate a real 60 MHz BW is at least 120 MHz (leaving no room at band edges), and for that case I would likely use 200 MHz which would be more than sufficient. This would result in the "1880 MHz carrier" being placed at 100 MHz.

Here is a close example I have that demonstrates this which was for a multi-carrier CDMA system (reverse link).

This is actually the radio receiver design but I draw your attention to the 35 MHz Digital IF, that is then represented with a 20 MHz sampling rate. In the end this is providing a real digital output (not a simulation) of what is at the 35 MHz carrier, which is also the same signal at the 1880 MHz carrier. The digital output is sampled at 20 MHz and centered at 5 MHz, which is $F_s/4$. The reason to center a real signal at or close to $F_s/4$ is that it maximizes the distance in frequency to the images, which in practical implementation such as what is shown, it simplifies the analog filtering required. In a simulation it will center your signal in the unique digital span.

This drawing may also help illustrate the point of not needing to simulate every cycle of the actual carrier:

A bandwidth modulated signal is shown in time and in frequency. For the case of time we see it as a vector moving around on the complex I Q plane versus time, changing in magnitude and phase (which is what we are interested in!). It moves relatively slowly due to being bandwidth limited (as opposed to white noise which would instantaneously be at any other arbitrary point at every next instant in time; we would just see a 2 dimensional Gaussian cloud in that case). In frequency we see the signal is centered at 0, and has some bandwidth as given by the rate of modulation and any filtering or similarly pulse shaping that was applied.

This next slide demonstrating frequency translation also helps to make the point I am trying to make here. On the left we see the same signal except at a carrier frequency of $F_o$. The IQ time domain plot in this case is showing how the phase and magnitude of the signal is changing versus time relative to the carrier.

Consider the carrier alone with no modulation: When the carrier is at 0 as in our first case, the IQ plot would be a vector of constant magnitude and angle, not moving versus time (If the angle was 0 and magnitude 1 then it would be e vector on the real or I-axis centered on the origin pointing to the right). When the carrier is a positive frequency 1880 MHz signal (and to simplify this description consider the signal to still be complex), the IQ diagram would now be a vector rotating counter-clockwise at the rate of 1880 MHz. If we could observe this with a strobe-light flashing at the same 1880 MHz rate synchronized to when the vector passes $1\angle 0$, we would then see the same case as when the carrier was at 0: a vector centered on the origin pointing to the right and not rotating. Consider the same thought process with the modulated signal as in the picture below. When the signal is at the 1880 MHz carrier, the IQ diagram would be spinning at the 1880 MHz rate, but if we could observe it with the strobe light as previously described, we would see how the magnitude and phase deviates from 1880 MHz over time at each sample of the strobe light, and it would look identical to the same signal centered at 0. Since the signal is changing so slowly compared to 1880 MHz, there is no need for the strobe light to be going that high of a rate, we could equivalently run the strobe light at some sub-multiple of 1880 MHz (such as 100 MHz) and still observe the same result with the signal centered at 0; as at the 1880 MHz rate the signal has changed insignificantly in magnitude and phase from the previous sample.

• Thanks a lot, what about sampling frequency is too small to simulate the carrier , so carrier should be incremented with finer time increments 1/((2Fc-B/)m) <= ts <= 1/((2Fc+B)/(m+1)) and the optimum is ts=1/((2Fc+B)/(m+1)), in general i wanna see multiple signals at different frequencies on the same spectrum – sh2017 Jun 11 '17 at 11:15
• Yes if you wanted to simulate the actual carrier, you would need a sampling frequency> 2x the carrier frequency to follow the Nyquist criteria and much greater if you wanted to be able to actually visualize the carrier. Usually there is no reason to do this and it is quite impractical given the ratio of your carrier frequency to your modulation rate (will be a very long simulation). The reason that you don't need to do this is because what happens at the carrier frequency to the modulated signal in terms of phase and amplitude occurs with the same signal at any other frequency including 0 – Dan Boschen Jun 11 '17 at 12:05
• Use complex processing (I and Q) to represent your signal and you can indeed include multiple signals at different frequencies--- just call 0 the 1880 MHz carrier without going through the painful effort to simulate all the sine waves at that carrier frequency. You are really interested in how the phase and magnitude changes over time of the envelope of the carrier; the rate at which the carrier itself oscillates is not important. – Dan Boschen Jun 11 '17 at 12:09
• i didn't see the signal on a carrier as replicas of the spectrum when using commands" [ii,oo]=psd(x,2^10); , plot((-length(oo)/2:(length(oo))/2-1)*Fs/4/length(oo),10*log10([ii(length(ii)/2+1:end); ii(1:length(ii)/2)]/max(ii)))" and "periodogram(x,rectwin(length(x)),length(x),Fs)", am i missing something ? – sh2017 Jun 11 '17 at 13:39
• You will only see the first Nyquist Zone: the range from $-F_s/2$ to $+F_s/2$. All the other frequencies are identical replicas of this one so there is no need to show them (as explained in more detail in the link I gave in my answer) – Dan Boschen Jun 11 '17 at 13:41