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
 For and if statment for sorting condition

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
zknauss Posted - 09/27/2022 : 11:19:21 AM
I am trying to write a for/if statement to label my data sets based on a condition. I have most of it working except for the very last line which defines whether to label the data as a "D" or "B". what I need it do is match the following rules:

1. if xx<5 the resulting value should be "D"
or
2. if bb==0 the resulting value should be "D"
or
3. if zz=="B" && bb<aa[40] the resulting value should be "D"
4. if the above are not true the resulting value should be "B"

I need this to be integratable with the first section of the working part. I've listed three versions of this script I've tried without any luck. I just get a constant output of "D" when I know I should be getting A,B,C in my data. Version 1 was my latest attemp and I tried flipping it around and baseing the calculation off "B" but still didn't work.

Part working:
for (int i = 2; i <= wks.ncols; i++ ){
range aa = [NCONFreReg]"Frequency_T1"!$(i);
range bb = [NCONFreReg]"Frequency_T2"!$(i);
range xx = [NCONT2Peak]"Peak Counts"!$(i);
range zz = [FreqSortNCON]"FRQSorting_N_CON"!$(i);
wcol(i)[2]$ = if(bb[2]>=aa[40]&&xx>5,"A",if(bb[2]<=aa[41]&&xx>5,"C",

Not working:

Version 1
if(xx>5&&bb[2]<aa[40]&&bb[2]>aa[41]&&zz[1]=="B","B","D")$)$)$; }

Version 2
if(bb[2]==0||xx<5 ||(zz[1]=="D"&&bb[2]<aa[40]),"D","B")$)$)$; }

Version 3
if(bb[2]==0||xx<5 ||if(zz[1]=="D"&&bb[2]<aa[40]),"D","B")$)$)$; }


ZTK
1   L A T E S T    R E P L I E S    (Newest First)
zknauss Posted - 09/27/2022 : 1:22:50 PM
Figured it out the issue was I needed to add another resultant to the formula:

if(bb[2]==0||xx<=5 ||if(zz[1]=="D"&&bb[2]<(aa[40]),"D"),"D","B")$)$)$; }

ZTK

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