import matplotlib.pyplot as plt
import numpy as np
import sys
from scipy import signal
type='fsk'
freq=10
Fs = 150.0; # sampling rate
Ts = 1.0/Fs; # sampling interval
t = np.arange(0,2,Ts)
if (type=='fsk'):
bit_arr = np.array([5,5,-5,5,-5])
samples_per_bit = 2*Fs/bit_arr.size
dd = np.repeat(bit_arr, samples_per_bit)
y= np.sin(2 * np.pi * (freq + dd) * t)
elif (type=='psk'):
bit_arr = np.array([180,180,0,180,0])
samples_per_bit = 2*Fs/bit_arr.size
dd = np.repeat(bit_arr, samples_per_bit)
y= np.sin(2 * np.pi * (freq) * t+(np.pi*dd/180))
else:
bit_arr = np.array([1, 0, 1, 1, 0])
samples_per_bit = 2*Fs/bit_arr.size
dd = np.repeat(bit_arr, samples_per_bit)
y= dd*np.sin(2 * np.pi * freq * t)
plt.plot(t,y)
plt.show()
No comments:
Post a Comment