Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from numpy import *
- from numpy.fft import fft
- import matplotlib.pyplot as plt
- def zad1():
- array = genfromtxt("spots.txt")
- n = len(array)
- fs = n/12
- signal = fft(array)
- signal = abs(signal)
- temp_signal = signal[1:]
- maximum = max(temp_signal)
- print(maximum)
- lista = list(signal)
- print(lista.index(maximum))
- t = linspace(0,fs,len(array), endpoint=False)
- plt.stem(t,signal)
- plt.show()
- def zad2():
- A = 1
- F = 1.0
- T = 1/F
- f = lambda t : (A * (sin(2*pi*t) + sin(4*pi*t)))
- LP = 10
- w = 20
- TW = 1/w
- t = arange(0, LP*T, TW)
- n = len(t)
- signal = f(t)
- signal1 = fft(signal)
- signal1 = abs(signal1)
- freqs = linspace(0, w, n)
- plt.stem(freqs, signal1, '-*')
- plt.show()
- def zad3():
- A = 1
- F = 1.0
- T = 1/F
- f = lambda t : (A * (sin(2*pi*t) + sin(4*pi*t)))
- LP = 10
- w = 20
- TW = 1/w
- t = arange(0, LP*T, TW)
- n = len(t)
- signal = f(t)
- signal1 = fft(signal)
- signal1 = abs(signal1)
- z = a+bi
- faza = arg(z)
- freqs = linspace(0, w, n)
- plt.plot(freqs, signal1, '-*')
- plt.plot(freqs, faza, '-^')
- plt.show()
- if __name__ == "__main__":
- zad1()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement