import numpy as np import scipy as sp import matplotlib.pyplot as plt # Modulation index beta = 2.0 A_c = 1 # Number of impulses is 2*(beta+1) + 1. # For beta=2, the number of impulses is 3 either side of the center frequency # plus 1 for the center frequency, for a total of 7 impulses. # Message frequency f_m = 15E+3 # Transmission bandwidth B_T = 2*(beta+1)*f_m print(B_T) n = np.arange(-3,4,1) bessel_values = np.abs(sp.special.jv(n,beta)) N = np.arange(-100,100) bessel_power = np.sum(np.abs(sp.special.jv(N,beta))) plt.stem(n, bessel_values) plt.plot(n, np.cumsum(bessel_values**2), label="Cumulative power in Carson rule bandwidth", color="red") #plt.plot(n, bessel_power) plt.hlines(0.98, xmin=n[0], xmax=n[-1], label="98% of total power", color="orange") plt.legend() plt.show() P_C = 0.5 * A_c**2 * np.sum(bessel_values**2) P = 0.5 * A_c**2 print("Percent of total power:", P_C / P)