Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import matplotlib.pyplot as plt
- w1 = 5 #1st freq
- w2 = 7 # 2nd freq
- t_f = 10 # timespan
- t = np.arange(0,t_f,0.001)
- wave_a = np.cos( w1*t )
- wave_b = np.cos( w2*t )
- wave_sum = np.cos( w1*t ) + np.cos( w2*t )
- wave_product = 2* np.cos(( w1 + w2)*t/2 ) * np.cos( (w1-w2)*t/2 )
- plt.figure(1) # initialisierung
- p = plt.subplot(3,1,1)
- plt.plot(t,wave_a,label=str(w1)+" Hz")
- plt.plot(t,wave_b,label=str(w2)+" Hz")
- plt.legend(bbox_to_anchor=(0., 1.02, 1., .102), loc=3,
- ncol=2, mode="expand", borderaxespad=0.)
- p = plt.subplot(3,1,2)
- plt.plot(t,wave_sum,label="Summe = cos( w1*t ) + cos( w2*t )")
- plt.legend(bbox_to_anchor=(0., 1.02, 1., .102), loc=3,
- ncol=2, mode="expand", borderaxespad=0.)
- p = plt.subplot(3,1,3)
- plt.plot(t,wave_product,label="Produkt = 2* cos( (w1 + w2)*t/2 ) * cos( (w1-w2)*t/2 )")
- plt.legend(bbox_to_anchor=(0., 1.02, 1., .102), loc=3,
- ncol=2, mode="expand", borderaxespad=0.)
- plt.tight_layout()
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement