How to generate random data with a specific bandwidth

I generate some random data (bits, actually, using MATLAB's randi) and then I convert such bits to BPSK (1 and -1). After that, I use a RRC pulse (roll-off factor of 0.35, 8 symbols and 4 samples per symbol) to create the waveform.

The bandwidth of the pulse-shaped BPSK then would be ($$\beta$$ is the roll-off factor):

$$BW = R_S(1+\beta)$$

My problem here is how to determine $$R_s$$ (data rate). I mean, I'm using randi, not an actual data source so initially I tried to make that value up. I suppose $$R_s=1MHz$$, after pulse shape the sampling frequency is $$f_s = sps*R_S = 4MHz$$ ($$sps=4$$ because of the 4 samples per symbol stated above), then the bandwidth should be something like $$BW=(1+0.35)1MHz=1.35MHz$$ and tried to plot the DFT of the pulse-shaped sequence for a final sampling rate of $$4 MHz$$:

As you can see, the bandwidth is nowhere near $$1.35 MHz$$.

So these are my questions:

1. How can I manipulate/control $$R_S$$
2. What's wrong with my calculations?

Thanks!

• I disagree with the explanation of the bandwidth issue in the accepted answer. You have an error in your formula: it should be $B = (R_s/2)(1+\beta)$ (you're missing a factor of 1/2). So, with a rate of one million and using sinc pulses ($\beta=0$), you'd need 500 kHz. With excess bandwidth 0.35, you need $500*1.3$ or 650 kHz, which is consistent with your result.
– MBaz
Oct 17 '19 at 19:19

How can I manipulate/control $$R_S$$?

You usually start with a desired pulse rate $$R_S$$. Then, the number of samples per symbol is $$f_sT_S$$, where $$f_s$$ is the sampling rate and $$T_S = 1/R_S$$. The resulting signal bandwidth will be $$B = (1+\beta)R_S/2$$, where $$\beta$$ is the excess bandwidth in the pulse you choose to use.

In other cases you have a desired bandwidth $$B$$. In that case, the pulse rate is determined from $$R_S = 2B/(1+\beta)$$. The sampling rate is again determined by how many samples per symbol you want.

If you go with higher-order or quadrature modulation, then each pulse will transmit $$k=2^M$$ bits, with $$M$$ the number of pulse amplitudes allowed. Then, $$R_S = R_b / k$$, where $$R_b$$ is the bit rate. The other equations above remain the same.

What's wrong with my calculations?

You missed a factor of $$1/2$$ in the bandwidth formula. With a rate $$R_S = 10^6$$ bits per second, using sinc pulses ($$β$$=0), you'd need $$B = 500\text{ kHz}$$. With excess bandwidth $$0.35$$, you need $$B = 500 \times 1.35 = 675\text{ kHz}$$, which is consistent with your result.

For completeness, here's some Matlab code and the resulting plot:

b = randi([0,1],10000,1); % generate bits
a = 2*b-1;  % generate pulse amplitudes
Rs = 1; % define the pulse rate
Ts = 1/Rs;
fs = 4; % define the sampling frequency
beta = 0.35; % define the EBW
p = rcosdesign(beta, 20, Ts*fs); % raised cosine pulse with 4 sps and 0.35 EBW
% Now we upsample the amplitudes by a factor fs.
a_up = upsample(a,fs);
% The transmitted signal is the convolution of a_up with p
s = conv(p,a_up);
% Let's see the spectrum of s:
S = fft(s);
L = length(s);
P2 = abs(S/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f = fs*(0:(L/2))/L;
plot(f,P1);
% Plot a line at the bandwidth
hold on; plot([0.675, 0.675], [0,0.02],'r'); hold off;


• Thanks for the answer, it really helped! I have only one question about your code, you do a_up = upsample(a,fs); but shouldn't it be a_up = upsample(a,Ts*fs); Oct 22 '19 at 11:25
• @researcher9 You're welcome! And yes, you're correct. In my example Ts=1, so the code works, but in general you need to upsample by Ts*fs.
– MBaz
Oct 22 '19 at 13:03
1. In the case of BPSK, the data rate equals the symbol rate (one bit per symbol). One way to control $$R_S$$ is to change the modulation. For example, you can increase the number of bits per symbol by choosing a higher order modulation like 16-QAM which has 4 bits per symbol.

2. There is nothing wrong with your calculation. The plot is a single sided spectrum so you only see half the bandwidth. It roughly dies off around half of 1.35 MHz so assuming your code is correct, I see nothing particularly wrong with the plot or calculation.