Skip to content

Instantly share code, notes, and snippets.

@nihalpasham
Last active April 12, 2020 04:39
Show Gist options
  • Save nihalpasham/f471ab92c620c7ad1671f21f8be1c460 to your computer and use it in GitHub Desktop.
Save nihalpasham/f471ab92c620c7ad1671f21f8be1c460 to your computer and use it in GitHub Desktop.
DSSS Code Sequence vs Sinc interpolated Code Signal
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.pyplot import step, xlim, ylim, show
k = 16
a = np.array([-1, -1, -1, -1, 1, -1, 1, -1, 1, 1, -1, -1, -1, 1, -1, -1, 1, 1, 1, 1, -1, -1, 1, -1, 1, -1, -1, 1, -1, -1, 1, -1, 1, 1, -1, 1, -1, 1, -1, 1, -1, -1, -1, -1, -1, 1, 1, -1, -1, 1, -1, -1, -1, -1, 1, 1, 1, -1, 1, -1, 1, 1, 1, -1, -1, 1, 1, 1, -1, -1, -1, 1, 1, -1, 1, 1, -1, -1, 1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, -1, 1, 1, 1, 1, 1, -1, 1, -1, -1, 1, 1, -1, 1, -1, -1, -1, 1, -1, 1, 1, 1, 1, -1, 1, 1, -1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1])
# code-sequence
b = np.tile(a, 1)
x = np.arange(0, 127)
# code-signal
upsampled_signal = upsample(b, k) # upsample is a function in the sinc interpolation module.
fig, (ax1, ax2) = plt.subplots(2, figsize=(17,13))
ax1.step(x, b)
ax1.set(xlabel='Sample Number', ylabel='Amplitude')
ax1.set_title('127-bit DSSS Binary Code Sequence', fontsize=12, fontweight="bold")
ax2.plot(us1, 'tab:green')
ax2.set(xlabel='Sample Number', ylabel='Amplitude')
ax2.set_title('Sinc Interpolated DSSS Code Signal', fontsize=12, fontweight="bold")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment