MATLAB: How to feel an array with 3 numbers randomly

programming

Hi,
I have an array say A, now it could contain 10,20,30 and 40 elements. Now I want to fill this array with 90,105,120 numbers randomly.
i.e my array would contain 10/20/30/40 elements but each time it have to be filled up with only 90,105,120 values randomly

Best Answer

Do I understand you correctly? In case of the 10 values array, you'd like to have e.g.
A=[90 120 105 105 120 90 90 90 120 105]
I'd go like this:
nums=[90 105 120];
A=nums(randi(3,1,10));
In case of 20 or more values, just change the third parameter in the randi function.