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
 Find and output several values using reducedup

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
mgehring Posted - 12/12/2016 : 11:07:59 AM
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
2   L A T E S T    R E P L I E S    (Newest First)
Hideo Fujii Posted - 12/13/2016 : 2:06:58 PM
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
yuki_wu Posted - 12/13/2016 : 02:06:23 AM
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

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