random between two numbers

nickv91's icon

Hi all!
How is possible in max to do a random number between a minimum and a maximum?
For example if i want random numbers between 5 and 8, only in this range how can i?

Thanks!!

brendan mccloskey's icon

Hi
to get 4 random numbers you need [random 4], which will generate numbers between 0 - 3, use [+ 5] to bring those values up to the required range.

Brendan

dapinsker's icon

Another method is to use the expr object. The random function allows you to determine the minimum and maximum range of numbers.

Marc P.

3722.Rnd.maxpat
Max Patch
nickv91's icon

Great!!!

nickv91's icon

Last question... and if i want to save this patch and turn it in a mxo how can i do? thanks

Mark Durham's icon

Kind of lazy, but I always use the [between] object in the RTC library.

Peter Castine's icon

.mxo's are written in C.

If you want to reuse your patch as an abstraction, save it as a .maxpat inside your search path and instantiate it by using the file name. BTW, this is all covered with nice, simple explanations in the Tutorials.

I'm also kind of lazy and just use lp.tata from Litter Power.