匹配数据集大小的插值
Interpolation to match dataset size
如果我有两个不同大小的数据集,例如:
x1 = [0,2,5,10,12,20,15,14] #length = 8
y1 = [0,0.3,0.6,1.1,1.3,2.1,1.6,1.5] #length = 8
x2 = [0,2,4,5,10,12,13,20,18,15,14] #length = 11
y2 = [0.3,0.4,0.5,0.7,1.1,1.3,1.4,2.2,1.6,1.9,1.8] #length = 11
如何让 x1,y1 数据匹配 x2,y2 数据大小?所以它们的长度都是 11.
我看过 scipy.interpolate
及其其他功能。但是我没有得到正确的数字,或者我使用了错误的函数。如果有人知道正确的功能或不同的方法来解决这个问题,那就太好了。
所以 x1,y1 的最终长度为 11。
我会使用 interp1
https://uk.mathworks.com/help/matlab/ref/interp1.html
x1i = interp1(1:8, x1, linspace(1,8,11), 'spline');
y1i = interp1(1:8, y1, linspace(1,8,11), 'spline');
如果我有两个不同大小的数据集,例如:
x1 = [0,2,5,10,12,20,15,14] #length = 8
y1 = [0,0.3,0.6,1.1,1.3,2.1,1.6,1.5] #length = 8
x2 = [0,2,4,5,10,12,13,20,18,15,14] #length = 11
y2 = [0.3,0.4,0.5,0.7,1.1,1.3,1.4,2.2,1.6,1.9,1.8] #length = 11
如何让 x1,y1 数据匹配 x2,y2 数据大小?所以它们的长度都是 11.
我看过 scipy.interpolate
及其其他功能。但是我没有得到正确的数字,或者我使用了错误的函数。如果有人知道正确的功能或不同的方法来解决这个问题,那就太好了。
所以 x1,y1 的最终长度为 11。
我会使用 interp1
https://uk.mathworks.com/help/matlab/ref/interp1.html
x1i = interp1(1:8, x1, linspace(1,8,11), 'spline');
y1i = interp1(1:8, y1, linspace(1,8,11), 'spline');