# Step 1: generate random set of bits
M=4
Nsymbols=10000
Nbits=log2(M)*Nsymbols
bits <- sample(0:1,Nbits, replace=TRUE)
# Step 2: Generate a BPSK modulated signal including raised cosine
# pulse shaping sampled at 64 samples per symbol period and roll-off
# factor of 0.5.
Ns=64
B=0.5
hx=seq(-4*Ns,4*Ns,by=1)
h=rcosine(hx,B,Ns)
s <- fqpskmod(bits,Ns,h)
# Step 3: Plot the transmitted waveform with the eyediagram function.
# Remove the initial 1000 and tail points for a cleaner diagram, i.e.
# without startup and tail artifacts
Np=3
No=27
# real part (in-phase)
eyediagram(s[1000:60000],Ns,Np,No,iq="r",xlab="Ts",ylab="I")
# imaginary part (quadrature)
eyediagram(s[1000:60000],Ns,Np,No,iq="q",xlab="Ts",ylab="Q")
Run the code above in your browser using DataLab