原MATLAB声明是-
Output = (interp2(X,Y,Tbl',Z,ThrtlPrcnt,'linear'));
其中参数值(Python中)是
X = array([0, 550, 600, 700, 800, 874, 900, 950, 1000, 1100, 1200, 1300, 1400,
1500, 1600, 1700, 1730, 2000, 2100, 2200, 2500, 3000], dtype=object)
Y =array([0, 1, 10, 20, 30, 40, 50, 70, 80, 100], dtype=object)
Tbl =
array([[-75, -226, -239, -271, -375, -453, -701, -759, -818, -997],
[-1269, -1716, -1967, -2028, -2056, -2104, -2106, -2124, -2130,
-2137],
[-2156, -2680, 463, -114, -166, -271, -375, -453, -701, -759],
[-818, -997, -1269, -1716, -1967, -2028, -2056, -2104, -2106,
-2124],
[-2130, -2137, -2156, -2680, 954, 285, 285, 285, 285, 167],
[125, 44, -32, -161, -290, -402, -521, -660, -800, -925],
[-970, -1318, -1426, -1534, -1857, -2679, 1106, 535, 535, 535],
[535, 417, 375, 294, 218, 89, -32, -152, -271, -391],
[-510, -637, -670, -969, -1080, -1191, -1524, -2331, 1258, 860],
[860, 860, 860, 809, 792, 759, 726, 648, 570, 500],
[400, 300, 185, 81, 46, -271, -389, -506, -858, -1634],
[1410, 1285, 1285, 1285, 1285, 1222, 1200, 1155, 1112, 1037],
[965, 890, 800, 700, 600, 500, 470, 150, 0, -150],
[-525, -1286, 1592, 1592, 1592, 1592, 1592, 1576, 1568, 1563],
[1554, 1518, 1483, 1432, 1381, 1329, 1261, 1157, 1119, 776],
[649, 522, 140, -590, 1867, 1944, 1937, 1924, 1910, 1901],
[1897, 1895, 1893, 1887, 1849, 1815, 1781, 1747, 1620, 1516],
[1477, 1125, 995, 864, 473, -242, 2019, 2144, 2137, 2124],
[2130, 2145, 2150, 2150, 2150, 2150, 2150, 2150, 2150, 2120],
[2009, 1880, 1850, 1550, 1420, 1290, 900, 200, 2383, 2536],
[2550, 2578, 2606, 2626, 2634, 2648, 2648, 2648, 2648, 2648],
[2620, 2520, 2369, 2234, 2193, 1823, 1686, 1549, 1139, 455]],
dtype=object)
Z =
array([600, 700, 800, 874, 900, 950, 1000, 1100, 1200, 1300, 1400, 1500,
1600, 1700, 1730], dtype=object)
ThrtlPrcnt = 100
我的预期输出是-
np.array([[2550],
[2578],
[2606],
[2626],
[2634],
[2648],
[2648],
[2648],
[2648],
[2648],
[2620],
[2520],
[2369],
[2234],
[2193]])
我试过scipy的BivariateSpline,bisplrep和bisplev,但没有运气。从上周开始就试过了,但没有成功。在1D插值中,即np.interp我们需要将MATLAB中的最后一个参数移动到Python中的第一个参数。我不知道2D是怎么回事。我错过了什么?
对于BivariateSpline获取错误- raise ValueError('z的x维度必须具有相同数量的' ValueError:z的x维必须有与x相同的元素数。
1条答案
按热度按时间bwleehnv1#
下面的代码为我工作完美-