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
 Origin Forum
 Extract data

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
gulitog1 Posted - 09/16/2012 : 12:17:56 PM
If I have two colums of data X and Y, and I want to extract the cell Y corresponding to a particular value of X, that is closest one to my target (for example,the closest value to X=1, which script can I use?
5   L A T E S T    R E P L I E S    (Newest First)
gulitog1 Posted - 09/22/2012 : 10:53:38 PM
quote:
Originally posted by greg

range raxy = (rax,ray) creates an XYRange out of rax (column 1) and ray (column 2) where rax is the 'x' and ray is the 'y'. I could interpolate the other way by using range rayx = (ray,rax).

InterpolatedY = raxy(1) finds the value of Y at X = 1 in the XYRange.

InterpolatedY is a scalar value, so:
col(3)=InterpolatedY
will not do anything unless you have set a data range for column 3. You could set a cell in column 3 with:
col(3)[1] = InterpolatedY


Thank you. But I don't have X=1, I have, for example,: X=0.9997,1,005,... How can I modify the script?
greg Posted - 09/19/2012 : 4:20:07 PM
range raxy = (rax,ray) creates an XYRange out of rax (column 1) and ray (column 2) where rax is the 'x' and ray is the 'y'. I could interpolate the other way by using range rayx = (ray,rax).

InterpolatedY = raxy(1) finds the value of Y at X = 1 in the XYRange.

InterpolatedY is a scalar value, so:
col(3)=InterpolatedY
will not do anything unless you have set a data range for column 3. You could set a cell in column 3 with:
col(3)[1] = InterpolatedY
gulitog1 Posted - 09/18/2012 : 3:00:02 PM
quote:
Originally posted by greg

Rather than the closest value, how about interpolating to get the estimated Y value at an exact X value?

range rax = [Book1]Sheet1!col(1);
range ray = [Book1]Sheet1!col(2);
range raxy = (rax,ray);
InterpolatedY = raxy(1);



Thank your for your reeply. After that do I need to insert a command like col(3)=InterpolatedY, because it does not seem to work. And the one afetr raxy, is it the target?
greg Posted - 09/17/2012 : 3:11:32 PM
Rather than the closest value, how about interpolating to get the estimated Y value at an exact X value?

range rax = [Book1]Sheet1!col(1);
range ray = [Book1]Sheet1!col(2);
range raxy = (rax,ray);
InterpolatedY = raxy(1);
Hideo Fujii Posted - 09/17/2012 : 1:52:39 PM
Hi gulitog1A

The following sample may serve your purpose:
////////////////////////////////////
function double difv(double v1, double v2) {
  return abs(v1-v2);
}
target=1;
minv=1e307;
Loop(ii,1,wks.maxRows) {
  d=difv(col(1)[ii], target);
  if(d<minv) { minv=d; mini=ii; }
}
//// Output results /////
worksheet -a 3;
nc=wks.ncols;
wcol(nc-2)[C]$=Index;  wcol(nc-2)[1]=mini;
wcol(nc-1)[C]$=X;      wcol(nc-1)[1]=col(1)[$(mini)];
wcol(nc)[C]$=Y;        wcol(nc)[1]=col(2)[$(mini)];
////////////////////////////////////

Hope this helps.

--Hideo Fujii
OriginLab

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