filter to choose between 2 values

Dec 6, 2013 at 8:03am

filter to choose between 2 values

hello,

i’m stuck at a point where i’m not sure what combination of if / route / gate / select objects i should use.

i have 2 variables: theta1, theta2
and 4 other variables: a, b, c, d

i want some kind of ‘filter’ that says:

if either ‘a’ or ‘b’ are equal to zero, then pass on “theta1″

if neither ‘a’ or ‘b’ are equal to zero, then compare ‘c’ and ‘d’.
if c>d then pass on “theta1″.
if c<=d then pass on "theta2".

ideas?
thanks.

#274961
Dec 6, 2013 at 9:17am

let me see…

a, b, c, d, theta1, theta2

[expr ((($f1==0)||($f2==0))*$f5)+(($f1!=0)&&($f2!=0))*((($f3>$f4)*$f5)+(($f3<=$f4)*$f6))]

(untested)

you might need to add some [t b f] triggers before the theta inputs.

-110

#274964
Dec 6, 2013 at 9:34am

oh, and you have to add a [prepend set] before the first inlet, to make it _not trigger an output when you _dont want it.

#274965
Dec 6, 2013 at 11:01am

thanks for the reply roman.

for some reason whenever i trigger an output i get the answer $f5 (theta1) no matter what the case is.

#274970
Dec 6, 2013 at 11:54am

i just got this suggestion from a friend and it works

<code>

– Pasted Max Patch, click to expand. –

</code>

#274979
Dec 6, 2013 at 12:26pm

You’re able to state your conditions logically, which is 50% of the job, so all you have to do is implement them in the given language. Here’s one way. (The pak object is just for easy input, to let you try different values for the variables; the evaluative code is in the if object.)
<code>

– Pasted Max Patch, click to expand. –

</code>

#274984
Dec 7, 2013 at 5:41pm

thanks a lot for the input christopher

#275062

You must be logged in to reply to this topic.