Forums > MaxMSP

Gradually accumulate numbers in a list until they are all equal

February 27, 2014 | 9:57 am

Hello,

I have a math question. I have a list of floats (35-40 numbers in the list) and I want to gradually add a set number to each one until they are all the same. I know I can add a number to each element in a list with vexpr  but can’t figure out how to do it as a continual accumulation. Further, Vexpr keeps truncating the decimal points of the floats.

 

Thanks for the help!


February 27, 2014 | 10:37 am

Something like this. [vexpr (($f1<$f2)*$f3) + $f1 @scalarmode 1] Where f1 is your list, f2 the number to match and f3 the amount to add to f1 to reach f2


February 27, 2014 | 11:04 am

you could first find the average or median or where ever you want to go, then use + or slide to do the steps.


February 28, 2014 | 5:30 am

I want to gradually add a set number to each one until they are all the same.

Does each list element need to add to exactly the same number via the same incremental value? If so, how are you deriving the number that will incrementally increase all of the list elements to the same value? If you were referencing integers I would be thinking in terms of a greatest common divisor, but you’re talking about floats.

I know I can add a number to each element in a list with vexpr but can’t figure out how to do it as a continual accumulation.

If you use a message box to input your list, you can feed the output of vexpr to the right inlet of the input message box… and keep clicking or banging the message box to input the newly updated list.

Further, Vexpr keeps truncating the decimal points of the floats.

Be sure you are using $f1 changeable args, not $i1.


February 28, 2014 | 2:27 pm

I like Rick’s approach. You can also use the minimum and clip objects so that your final output is a list of identical values.

– Pasted Max Patch, click to expand. –

March 1, 2014 | 5:51 pm

Thanks so much–this solution works perfectly!


Viewing 6 posts - 1 through 6 (of 6 total)