0

I have a data file with 2 columns. First column runs from 0 to 1390 second column has different values. (1st column is X pixel coordinates 2nd is intensity values).

I would like to "stretch" the data so that the first column runs from 0 to 1516 and the second column gets linearly interpolated for these new datapoints.

Any simple way to do this in scilab?

Data looks like this: 0 300.333 1 289.667 2 273 ... 1388 427 1389 393.667 1390 252

4

2 回答 2

1

问题是如何将 y 向量从 1391 个值“拉伸”到 1517 个值。可以按照@user1149326 的建议使用 interpln 来做到这一点,但我们需要在插值之前拉伸 x 向量:

x=[0 1 2 1388 1389 1390];
y=[300.333 289.667 273 427 393.667 252];    
d=1391/1517;
x2=0:d:1390;
yi=interpln([x;y],x2);
x3=0:1516;
plot2d(x3',yi',[3],"000");
于 2015-12-04T18:59:31.567 回答
1

插值

您可以使用 进行线性插值interpln在docs上的演示实现之后,这将产生以下代码。

示例代码

x=[0 1 2 1388 1389 1390];
y=[300.333 289.667 273 427 393.667 252];

plot2d(x',y',[-3],"011"," ",[-10,0,1400, 500]);

yi=interpln([x;y],0:1390);

plot2d((0:1390)',yi',[3],"000");

结果图

线性插值

外推

我认为您正在考虑外推,因为它超出了已知的测量范围,而不是介于两者之间。

您应该确定是否要拟合数据datafit。有关教程,请参见此处此处

于 2015-12-03T13:43:18.783 回答