MATLAB: Generate random numbers outside a range random number generator How can I generate random numbers outside a specific range? I want to generate random numbers outside the interval of [-1,3] Best Answer a = -10;b = 10;r = (b-a).*rand(1000,1) + a;%%remove the range [-1 3] r1 = r ;r1(r>=-1 & r<=3) = []; Related SolutionsMATLAB: Random numbers help randdoc rand MATLAB: Hello Please help how to generate a single random number between 6 and 8 Did you happen to look up rand() in the help and see the example:Create a vector of 1000 random values. Use the rand function to draw the values from a uniform distribution in the open interval, (50,100).a = 50;b = 100;r = (b-a).*rand(1000,1) + a;So your code would ber = 2 .* rand(1) + 6; Related QuestionGenerating random integer from -x to xHow to create random double in specific rangeFind a command that will generate a pseudo-random number(random number) that lies bwtween -1 and 1 drawn from uniform distributionHow to generate the random number with restrictionsRandperm for decimals/below 1
Best Answer