Hi,
Origin C provides a function ocmath_interpolate(can search this by Find in Files in Code Builder, or refer to help file) to interpolate a value at specified position, you may wrap this function by write a simple Origin C function invokable to Labtalk(solution A), or write your own X-Function to call ocmath_interpolate(solution B).
A simple way(as suggested as solution A mentioned above) is to write a function in an Origin C file(make sure the Origin C file in added into workspace in Code Builder and built successfully, so the function can be called by Labtalk through Script Window).
double user_interpolate_y_at_x(vector vX, vector vY, double xPos)
{
double dYVal = 0;
int nSrcSize = vX.GetSize();
ASSERT(nSrcSize == vY.GetSize());
int nRet = ocmath_interpolate(&xPos, &dYVal, 1, vX, vY, nSrcSize);
if ( nRet != 0 )
dYVal = NANUM;
return dYVal;
}
then you can call the function like
dRet = user_interpolate_y_at_x(Book1_A, Book1_B, 3.2);
in Script Window, dRet contains the result.
quote:
Originally posted by P.G.
Origin Ver. 2015
Operating System: Win 7
Hello everyone,
I am trying to wirte an LabTalk-Script and I need special values from an interpolation.
I have given data A and B and I use interp1 ix:= A iy:=B to create an interpolation of the Data.
Now i have a given value, lets say x which is somewhere between the Data in A so it must be in the interpolation of A and B and I want the corresponding value from B, which is here called y.
Is there a way to calculate the y value from the given x value in LabTalk?
I am trying to wirte a bigger Code so I can not use the tools that one can call "by hand", but only "by code".
Greetings