Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #to start with marplotlib
- #ipython --pylab
- import numpy as np
- from scipy.signal import tiang
- from scipy.fftpack import fft
- x = triang(15) #triangular function
- x = fft(x)
- mX = abs(X)
- pX = np.angle(X)
- #########################################
- plot(x)
- plot(mX) #magnitude and phase. first half are positive, second half are negative
- plot(pX) #phase should be zero, why? Because time signal was not centered around zero (it had a shift)
- #########################################
- #center around zero
- x = triang(15)
- fftbuffer = np.zeros(15)
- fftbuffer[:8] = x[7:] #from beginning to 8
- fftbuffer[8:] = x[:7] #from 8 to end
- X = fft(fftbuffer)
- mX = abs(X)
- pX = np.angle(X)
- #########################################
- plot(fftbuffer) #v shaped
- plot(mX) #magnitude spectrum. no change
- plot(pX) #phase is different
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement