matlab randomly select number from array code example Example: select random number from array matlab num = randi(length(x)); % x is an array