Skip to content

Instantly share code, notes, and snippets.

@ktatar
Last active February 23, 2020 20:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ktatar/2573bede64fb6c53da205cd67474da72 to your computer and use it in GitHub Desktop.
Save ktatar/2573bede64fb6c53da205cd67474da72 to your computer and use it in GitHub Desktop.
[Stretch a 1d numpy array] #python #numpy #signalprocessing #scipy #interpolate
import numpy as np
from scipy import interpolate
#Create target array. We are trying to match the size of this array
my_cqt = np.linspace(2.0,3.0, num=20)
#The array to be stretched
my_alfa = np.linspace(0., 1., num=10)
f = interpolate.interp1d(np.arange(0, len(my_alfa)), my_alfa)
my_stretched_alfa = f(np.linspace(0.0, len(my_alfa)-1, len(my_cqt)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment