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