带样条的矢量拟合误差(插值)

时间:2013-09-05 07:06:50

标签: matlab vector interpolation spline data-fitting

我在装载矢量时遇到了问题。

我有2条具有相同功能的曲线,我想比较一下。但每条曲线都有另一个时间向量,因为它们有不同的采样率(只有tstart = 0和tend = 8.853958是相同的)。

所以我试着将短矢量插入到与长矢量相同的长度......但我不明白它...在其他模拟中它起作用......但不是在这里......

错误信息是:

使用chckxy时出错(第51行) 数据网站应该是截然不同的。

样条曲线错误(第54行) [x,y,sizey,endslopes] = chckxy(x,y);

Labor_2ndReceiver出错(第434行)

dInt = spline(tspline,d,t1);

我的代码:

tstart = 0;
tstep = 1/fs;
tend = (pi/((1/5)*2))-tstep;
tendSync = 1;                       %Wait for 1 sec

t0 = tstart:tstep:tendSync;         %Time for synchronisation
t01 = tendSync+tstep:tstep:tend;    %Time after synchronisation to Tend
t1 = [t0 t01];                      %Complete Time

dInt = spline(tspline,d,t1);

,其中

%tspline <1x32605 double>:

%Columns 1 through 24000 all values are '1' 
%and Column 24001 is 0.249041666666667 
%and Column 24002 to 32605 are some increasing values to 8.852958333333334 (but without a constant sampling rate) 

%d <1x32605 double>; t1 <1x424992 double>

你能帮帮我吗?这非常重要......

非常感谢你!

编辑: 谢谢,但仍有问题...见图...

tspline =0:t1(end)/length(d):t1(end)-t1(end)/length(d);
dInt = spline(tspline,d,t1);

所以Interpolation有效...但是值是错误的...因为dInt开始得太晚了......它像d一样开始喊..

我怎么解决这个问题?

http://postimg.org/image/s8hnk1621/

1 个答案:

答案 0 :(得分:2)

您正在发出

dInt = spline(tspline,d,t1);

%tspline <1x32605 double>:

% Columns 1 through 24000 all values are '1' 

并且存在问题。您使用tspline作为曲线的x位置, all 应该是唯一的。

想一想:如何通过这个数据集插入曲线?

enter image description here