MATLAB: How to generate random number within a range MATLAB I want to generate a random number between 0.2 to 1 Best Answer >> 0.2+(1-0.2)*rand()ans = 0.85178 Related SolutionsMATLAB: How to Generate a Random # Between -1 and 1 Did you look in the help where is told you how to get a number in the range from a to b?r = 2 * rand - 1; MATLAB: How to generate a random decimal number between -1 and 1 The inputs to rand define its output size, not the output value range. Its range is fixed to 0..1, but you can adjust generate other values using some simple operations:2*rand()-1ans = -0.7192 Related QuestionRandom numbersHow to generate specific number of specific integers within a range
Best Answer