if else operation with two waves
kh121
I am still new to igor so I'll hope you can help me:
I would like to implement a conditional statement on one wave which leads to a change in another:
so I have two waves: C13factor and Br79_normC13:
if C13factor >1 the following operation shall be done: Br79_normC13*(1-(abs(1-C13factor)))
if C13factor <1: Br79_normC13*(1+(1-C13factor))
This is how my code looked so far but the outcome wave Br79_normC13 hasn't the right numbers.
if (C13factor>1)
Br79_normC13=Br79_normC13*(1-(abs(1-C13factor)))
else
Br79_normC13=Br79_normC13*(1+(1-C13factor))
endif
I think this is what you want. Note that C13Factor == 1 is dealt with as C13Factor < 1.
May 30, 2017 at 04:36 am - Permalink
You would need something like:
for (i=0; i<n; i+=1)
if (C13factor[i]>1)
Br79_normC13[i]=Br79_normC13[i]*(1-(abs(1-C13factor[i])))
else
Br79_normC13[i]=Br79_normC13[i]*(1+(1-C13factor[i]))
endif
endfor
After writing the above I realized there's also another easy way,
make /o/np ifthenthis= Br79_normC13*(1-(abs(1-C13factor)))
make /o/np ifelsethis= Br79_normC13*(1+(1-C13factor))
Br79_normC13[]= C13factor[p]>1 ? ifthenthis[p] : ifelsethis[p]
May 30, 2017 at 05:10 am - Permalink
May 30, 2017 at 08:03 am - Permalink