Wednesday, January 1, 2020

fft

FFT of two sine waves together
from scipy.fftpack import fft
import matplotlib.pyplot as plt
import numpy as np
# Number of sample points
N = 600
# sample spacing
T = 1.0 / 800.0
x = np.linspace(0.0, N*T, N)
y = np.sin(50.0 * 2.0*np.pi*x) + 0.5*np.sin(80.0 * 2.0*np.pi*x)
yf = fft(y)
xf = np.linspace(0.0, 1.0/(2.0*T), N//2)
plt.plot(xf, 2.0/N * np.abs(yf[0:N//2]))
plt.grid()
plt.show()

QPSK
 from numpy import ones,arange,cos,sin,pi
from matplotlib.pyplot import plot,subplot,title,xlabel,ylabel,show
M =4#
i = range(0,M)
t = arange(0,0.001+1,0.001)
s1=ones([len(i),len(t)])
s2=ones([len(i),len(t)])
for i in range(0,M):
  s1[i,:] = [cos(2*pi*2*tt)*cos((2*i-1)*pi/4) for tt in t]
  s2[i,:] = [-sin(2*pi*2*tt)*sin((2*i-1)*pi/4) for tt in t]
S1 =[]#
S2 = []#
S = []#
m =[0,1,0,1,1,0,1,1]
for i in range(0,len(m)):
  S1 = s1[m[i],:]
  S2 = s2[m[i],:]
  S = S+[S1*S2]
subplot(3,1,1)
plot(S1)
title('Binary PSK wave of Odd-numbered bits of input sequence')
subplot(3,1,2)
plot(S2)
title('Binary PSK wave of Even-numbered bits of input sequence')
subplot(3,1,3)
plot(S)
title('QPSK waveform')
show()

No comments:

Post a Comment

qpsk

from numpy import ones,arange,cos,sin,pi from matplotlib.pyplot import plot,subplot,title,xlabel,ylabel,show M =4# i = range(0,M) t = a...