MATLAB: How to create an array using an existing set of numbers longer than the original array

random number generation

Hi. I have this array: a = [20 10 5 1];
I need to create an array which will be of length n (n must be longer than the length(a)) This array should be comprised only of those numbers in array a.
How do I go about this? Thanks!

Best Answer

a( randi(length(a),1,n) )