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