MATLAB: Generation of an Odd numbers only

generateoddrandom

Hello every one I would like to generate a series of random odd numbers with in a specific range for example the range from 1 to 20 the odd number for example 1,3,5,7,9,11,13,15,17,19

Best Answer

My approach:
x = 1:20;
odv = x(rem(x,2)==1);
n = 10; % Length Of Series
oddrnd = odv(randi(length(odv),1,n));