45 lines
752 B
Python
45 lines
752 B
Python
import numpy as np
|
|
import scipy as sp
|
|
import matplotlib.pyplot as plt
|
|
|
|
f_c = 1
|
|
f_m = f_c/4
|
|
f_s = 8E3
|
|
T_s = 1/f_s
|
|
|
|
A_c = 1
|
|
|
|
omega_m = 2*np.pi*f_m
|
|
omega_c = 2*np.pi*f_c
|
|
|
|
# Time samples to 10 seconds at a samplig frequency of 8kHz
|
|
t = np.arange(0,10,T_s)
|
|
m = np.cos(omega_m * t)
|
|
|
|
plt.subplot(311)
|
|
plt.plot(t, m, label="$m(t)$")
|
|
plt.ylabel("$m(t)$")
|
|
|
|
D_p = np.pi
|
|
D_f = np.pi
|
|
|
|
# The phase modulated signal
|
|
S_p = np.cos(omega_c*t + D_p*m)
|
|
|
|
plt.subplot(312)
|
|
plt.ylabel("$S_p(t)$")
|
|
plt.xlabel("t (seconds)")
|
|
plt.plot(t,S_p)
|
|
|
|
# The time integral of the mesage signal
|
|
M = np.sin(omega_m * t) / omega_m
|
|
|
|
# The frequency modulated signal
|
|
S_f = np.cos(omega_c*t + D_f*M)
|
|
|
|
plt.subplot(414)
|
|
plt.ylabel("$S_f(t)$")
|
|
plt.xlabel("t (seconds)")
|
|
plt.plot(t,S_f)
|
|
plt.show()
|