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

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Padre
  • 89
  • 6

2 Answers2

1

Interpolation

You can linearly interpolate using interpln. Following the demo implementation on the docs, this results in the below code.

Example code

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");

Resulting plot

Linear interpolation

Extrapolation

I think you are thinking of extrapolation, since it is outside the known measurements and not in between.

You should determine if you would like to fit the data datafit. For a tutorial see here or here.

spoorcc
  • 2,907
  • 2
  • 21
  • 29
1

The question was how to "stretch" the y vector from 1391 values to 1517 values. It is possible to do that with interpln as suggested by @user1149326 but we need to stretch the x vector before the interpolation:

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");
David Dorchies
  • 336
  • 2
  • 11