MATLAB: How to generate a random number that is negative or positive and between two other values

functionsrandom number generator

I need to write a function that generates two numbers that are between the negative and positive values of an integer. For example, if I call the function and input 7 it should generate two random numbers between -7 and +7. I can't figure out a way to use the randi function because the values I need can't be just integers.

Best Answer

Hint: rand()-1/2 is in the range -1/2 to +1/2