Advertisement
naren_paste

Interpolation

Oct 17th, 2023
861
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.37 KB | Source Code | 0 0
  1. import numpy as np
  2. from scipy.interpolate import interp1d
  3.  
  4. x1 = np.array([1, 2, 3, 4, 5, 45])
  5. y1 = np.array([1, 8, 27, 64, 125, 91125])
  6.  
  7. # Create an interpolation function
  8. f = interp1d(x1, y1, kind='linear', fill_value='extrapolate')
  9.  
  10. # Define x_new
  11. x_new = np.linspace(1, 45, 10)
  12.  
  13. # Interpolate y values
  14. y_interp = f(x_new)
  15.  
  16. # Print the result
  17. print(y_interp)
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement