# How to create a 2D array of weighted+shifted unit impulses?

Advertisements I’m looking for an efficient way to get a 2D array like this: array([[ 2., -0., -0., 0., -0., -0., 0., 0., -0., 0.], [ 0., -1., -0., 0., -0., -0., 0., 0., -0., 0.], [ 0., -0., -5., 0., -0., -0., 0., 0., -0., 0.], [ 0., -0., -0., 2., -0., -0., 0.,… Read More How to create a 2D array of weighted+shifted unit impulses?

# How to split a signal in to chunks with the help of Blackman window using Numpy python

Advertisements For a given audio signal I want it to be spitted in to 50ms chunks to perform Fourier Transform. The problem is when I use the usual split method in Numpy it adds some high frequency components due to sudden split. So to solve this I heard we have to use a proper window.… Read More How to split a signal in to chunks with the help of Blackman window using Numpy python

# How do I read 1 dimensional data from a text file into a 1D array? [Python]

Advertisements I have a text file DATALOG1.TXT with values from 0 to 1023, pertaining to a signal. The file has one value per row, all values stored in a column. Here is an example of how the first values are stored in the file: 0 0 576 0 643 60 0 1012 0 455 69… Read More How do I read 1 dimensional data from a text file into a 1D array? [Python]

# Aliasing in Python even though under Nyquist rate

Advertisements From my understanding, the following code creates a 1 second long sine wave sampled at 256 Hz, meaning a Nyquist rate of 128 Hz. So if a sine wave is having a frequency of 100 Hz, it should not experience aliasing. t = np.linspace(0,1,256) x = np.sin(2*np.pi*100*t) plt.plot(t,x) However, the plot looks something like… Read More Aliasing in Python even though under Nyquist rate

# Is there a way to generate multiple sine waves without using loop in Python?

Advertisements I am trying to generate multiple sine waves, but I want to avoid using loops. Is there a way to do it as in MATLAB? Here is what I tried: fs =250 n = np.linspace(0,2,int(fs*2),endpoint=False) frequencies = [1,3,4,12,70] sines = np.sin(2*np.pi*frequencies*n) When I tried this code I got the following error: ValueError: operands could… Read More Is there a way to generate multiple sine waves without using loop in Python?