filter to choose between 2 values

desettled's icon

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

ideas?
thanks.

Roman Thilenius's icon

let me see...

a, b, c, d, theta1, theta2

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

(untested)

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

-110

Roman Thilenius's icon

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.

desettled's icon

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.

desettled's icon
Max Patch
Copy patch and select New From Clipboard in Max.

i just got this suggestion from a friend and it works

Christopher Dobrian's icon
Max Patch
Copy patch and select New From Clipboard in Max.

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.)

desettled's icon

thanks a lot for the input christopher