scilabstretching

Scilab Data stretching


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


Solution

  • 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.