how use random in array

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

how use random in array

LucaLuca
hi,
i 've array  a=[3,4,5]

i want to choise an element of a with random instruction


how i do it?







--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: how use random in array

Ian McCallion
a{1+floor(rand*3))

Ian
On Tue, 18 Sep 2018 at 14:27, LucaLuca <[hidden email]> wrote:

>
> hi,
> i 've array  a=[3,4,5]
>
> i want to choise an element of a with random instruction
>
>
> how i do it?
>
>
>
>
>
>
>
> --
> Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html
>
>


Reply | Threaded
Open this post in threaded view
|

Re: how use random in array

Leloup
a = 3+floor(rand(1,1000)*3)  



--
Sent from: http://octave.1599824.n4.nabble.com/Octave-General-f1599825.html


Reply | Threaded
Open this post in threaded view
|

Re: how use random in array

LucaLuca
In reply to this post by Ian McCallion