Python Forum
Python equivalent of Matlab code
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python equivalent of Matlab code
#2
If you have a meshgrid data, e.g.
import numpy as np
# x, y -- 1D arrays
X, Y = np.meshgrid(x, y)
# Z is a matrix, 
you can always do

interpolate.interp2d(X.ravel(), Y.ravel(), Z.ravel())
Another option, that should also work, is
interpolate.interp2d(x, y, Z)
It seems (from the docs) that MatLab's interp2 and scipy's interp2d do not differ significantly.
Reply


Messages In This Thread
Python equivalent of Matlab code - by kwokmaster - Mar-15-2020, 04:58 PM
RE: Python equivalent of Matlab code - by scidam - Mar-16-2020, 11:36 AM
RE: Python equivalent of Matlab code - by scidam - Apr-01-2020, 01:22 AM
RE: Python equivalent of Matlab code - by scidam - Apr-03-2020, 12:02 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  problem of converting Matlab code to python DongyanZ 2 1,434 Feb-03-2023, 01:04 PM
Last Post: jefsummers
  Convolution "same" in Python doesn't work as Matlab claw91 4 3,837 Oct-01-2020, 08:59 AM
Last Post: claw91
  Is there similar function to lsqnonlin (in matlab) in python? Jay_Nerella 1 6,009 Nov-11-2019, 08:40 AM
Last Post: feli_x
  Matlab to Python Ariane 6 7,144 Jun-14-2018, 12:08 PM
Last Post: Ariane
  How to use .m matlab file in python ? sameer 5 15,476 May-10-2018, 09:39 AM
Last Post: wavic
  What is the equivalent python code for c program? nvnkumrawat 10 5,977 Jan-09-2018, 07:22 PM
Last Post: Windspar
  Importing matlab cell array (.mat) into a python list scanato 0 8,691 Nov-15-2017, 11:04 AM
Last Post: scanato

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020