Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import matplotlib.pyplot as plt
- #Definere funksjonar for utrekning av bølgjene:
- def f(A,k,x,c):
- return A*np.sin(k*x+c)
- def g(A2,k2,x,c2):
- return A2*np.sin(k2*x+c2)
- #Få data frå brukaren:
- A = float(input("Skriv inn verdi for A: "))
- k = float(input("Skriv inn verdi for k: "))
- c = float(input("Skriv inn verdi for c: "))
- A2 = float(input("Skriv inn verdi for A2: "))
- k2 = float(input("Skriv inn verdi for k2: "))
- c2 = float(input("Skriv inn verdi for c2: "))
- #Bølgjene kvar for seg:
- fig = plt.figure()
- ax1 = fig.add_subplot(111)
- ax1.grid(True)
- x = np.linspace(0, 8*np.pi, 1000)
- plt.ylim(-10,10)
- ax1.plot(x,f(A,k,x,c))
- ax1.plot(x,g(A2,k2,x,c2))
- #Bølgjene overlagra:
- fig = plt.figure()
- ax2 = fig.add_subplot(111)
- ax2.grid(True)
- x = np.linspace(0, 8*np.pi, 1000)
- plt.ylim(-10,10)
- ax2.plot(x,f(A,k,x,c)+g(A2,k2,x,c2))
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement