The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Interpolation

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
P.G. Posted - 03/04/2015 : 09:22:52 AM
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
3   L A T E S T    R E P L I E S    (Newest First)
P.G. Posted - 03/10/2015 : 04:21:25 AM
Yes thank you everything looks good now.
Hideo Fujii Posted - 03/06/2015 : 3:04:04 PM
Hi P.G.,

You can also consider to use the XY data range as a function to get the interpolated Y value from given X. So, once you run interp1, then by using its result as a function, you can get new Y from a specific X. See:
http://www.originlab.com/doc/LabTalk/guide/Interpolation#Using_XY_Range

Does it help?

--Hideo Fujii
OriginLab
Sophy Posted - 03/04/2015 : 9:19:08 PM

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



The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000