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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Find and output several values using reducedup
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

mgehring

Germany
1 Posts

Posted - 12/12/2016 :  11:07:59 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi.
Is it possible to access the values of two columns using a single
reducedup
or similar command?

So basically, let's say I have three columns A, B, and C. The values in Column A are monotonic with a random number of duplicates. B is strictly monotonic and C are random values.
So far I was only interested in the maximum value of C for each unique value in A, which is easily accomplished using:
reducedup iy:=(col(A),col(C)) method:=max;

However, I now also need the corresponding value in B. Unfortunately, there is no possibility to sort or group the values in B to use the
reducedup
in a similar way to A.

I assume the solution is some kind of a loop or filtering by A in some way. In addition to not knowing how to do this, it would also require a way to sequentially output the data into rows of one column instead of a new column each, which I also do not know how to accomplish.

Any help is much appreciated.
Cheers,
Markus

Origin Ver. and Service Release (Select Help-->About Origin): 2017 (64-bit)
Operating System: Win7

yuki_wu

896 Posts

Posted - 12/13/2016 :  02:06:23 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

I think you can perform 1D interpolation or extrapolation on column(B) and column (C). Please take a look at this knowledge base item and see if this applies to you:
http://www.originlab.com/doc/LabTalk/ref/Interp-func

For example:
//There are three columns in [Book1]Sheet1! as what you said
reducedup -r 2 iy:=[Book1]Sheet1!(A,C) method:=max;
range wks=!;
wks.col3.type =4; //set column(c) as X
wks.col5.type=4; // set column(e) as X
col(6)=Interp(col(5),col(3),col(2));

Hope it help.

Regards,

Yuki
Go to Top of Page

Hideo Fujii

USA
1582 Posts

Posted - 12/13/2016 :  2:06:58 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Markus,

Here is a version of script which simply searches and gets the positions of the max values in duplication blocks:
////////////////////////////////////////////////////////
reducedup -r 2 iy:=(col(A),col(C)) method:=max xcount:=<new>; //reduce dups, and extract dup Xs with count
worksheet -a 3; //add 3 columns
csetvalue col:=col(H) formula:="list(col(F),col(A))"; //Start row of dup block
csetvalue col:=col(I) formula:="col(E)[xindex(col(F),col(E))]"; //Max in dup block
range rf=col(F);
for(ii=1 ; ii>0; ii++) { //loop over duplication block
  if(rf[ii]==NA()) Break;
  for(jj=1; jj<=col(G)[ii]; jj++) { //loop within dup block
    if(col(I)[ii]==col(C)[col(H)[ii]+jj-1]) { //find max position
      col(J)[ii]=col(B)[col(H)[ii]+jj-1];
      Break;
    }
  }
}
////////////////////////////////////////////////////////



Hope this helps.

--Hideo Fujii
OriginLab
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000