Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

frequency spectrum signal python

#A short example to extract the frequency spectrum of a signal
import numpy as np
import matplotlib.pyplot as plot
samplingFrequency  = 100
t=np.arange(0,5,1/samplingFrequency)
signal=np.sin(2*np.pi*t)
fourierTransform = np.fft.fft(signal)/len(signal)
fourierTransform = fourierTransform[range(int(len(signal)/2))]
tpCount     = len(signal)
values      = np.arange(int(tpCount/2))
timePeriod  = tpCount/samplingFrequency
frequencies = values/timePeriod
plt.plot(frequencies, abs(fourierTransform))
Comment

PREVIOUS NEXT
Code Example
Python :: how to detect language python 
Python :: converting binary to octal in python 
Python :: pip is not a batch command but python is installed 
Python :: python numpy array delete multiple columns 
Python :: python remove last element from list 
Python :: python cv2 get image shape 
Python :: pathlib get extension 
Python :: 2 variables with statement python 
Python :: Simple way to measure cell execution time in jupyter notebook 
Python :: pandas replace colomns location 
Python :: Simple pagination wrapper for discord.py. 
Python :: np deep copy matrix 
Python :: dataframe groupby multiple columns 
Python :: Inconsistent use of tabs and spaces in indentationPylance 
Python :: pandas rename column by index 
Python :: create an empty dataframe 
Python :: second y axis matplotlib 
Python :: update set python 
Python :: pandas shift all columns 
Python :: extend a class python 
Python :: pil image resize not working 
Python :: how to get the first few lines of an ndarray 3d 
Python :: check if camera is being used python 
Python :: python test is nan 
Python :: pgcd python 
Python :: import pil pycharm 
Python :: python requests post 
Python :: python parse url get parameters 
Python :: how to run bash script in python 
Python :: ValueError: `logits` and `labels` must have the same shape, received ((None, 2) vs (None, 1)). 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =