I am new to python and an amateur programmer so please bear with me. Right now I have a matrix which is 15x9. I essentially want to expand this matrix such that it contains more values. Thus I want to interpolate this data a number times, similar to the interp2 function in MATLAB which allows you to interpolate n times.
If you could perhaps show me a function that perform this task or even steps as to how to solve this problem any help would be greatly appreciated.
我是python的新手和业余程序员,所以请宽容我。现在我有一个矩阵,它是15x9。我想要扩展这个矩阵,使它包含更多的值。因此,我想要把这个数据插入一个数字时代,类似于MATLAB中的interp2函数,它允许你插入n次。如果您可以向我展示一个执行这个任务的函数,或者甚至是关于如何解决这个问题的步骤,您将非常感激。
Sorry I should have stated this before, but yes I am using a numpy array, not a list.
对不起,我之前应该说过,但是我使用的是numpy数组,而不是列表。
2 个解决方案
#1
1
I have encountered the same issue, and figured out that scipy.ndimage.map_coordinates
does the same as Vq = interp2(V,Xq,Yq)
. Please read the documentation of these commands to find out the solution for your case.
我也遇到过同样的问题,并发现了这个问题。map_坐标与Vq = interp2(V,Xq,Yq)相同。请阅读这些命令的文档,找出你的案例的解决方案。
Try this for Matlab's Vq = interp2(V,Xq,Yq)
:
尝试用Matlab的Vq = interp2(V,Xq,Yq):
Vq = scipy.ndimage.map_coordinates(V, [Xq.ravel(), Yq.ravel()], order=3, mode='nearest').reshape(V.shape)
#2
0
Use griddata from scipy.
使用来自scipy griddata。
Tutorial here: http://docs.scipy.org/doc/scipy/reference/tutorial/interpolate.html
教程:http://docs.scipy.org/doc/scipy/reference/tutorial/interpolate.html
#1
1
I have encountered the same issue, and figured out that scipy.ndimage.map_coordinates
does the same as Vq = interp2(V,Xq,Yq)
. Please read the documentation of these commands to find out the solution for your case.
我也遇到过同样的问题,并发现了这个问题。map_坐标与Vq = interp2(V,Xq,Yq)相同。请阅读这些命令的文档,找出你的案例的解决方案。
Try this for Matlab's Vq = interp2(V,Xq,Yq)
:
尝试用Matlab的Vq = interp2(V,Xq,Yq):
Vq = scipy.ndimage.map_coordinates(V, [Xq.ravel(), Yq.ravel()], order=3, mode='nearest').reshape(V.shape)
#2
0
Use griddata from scipy.
使用来自scipy griddata。
Tutorial here: http://docs.scipy.org/doc/scipy/reference/tutorial/interpolate.html
教程:http://docs.scipy.org/doc/scipy/reference/tutorial/interpolate.html