MATLAB: Uniformly distributed 10 number between [-100,100]

distributionuniform distribution

Hi,
I want to generate x with 10 numbers which are uniformly distributed between [-100,100]. Can you please tell which method is preferable? Are both methods are correct?
Method 1:
N = 10;
x = (-1:2/N:1-1/N).* 100;
Method 2:
uRand = rand(1,N);
x = (uRand.*2-1).*100;

Best Answer

If you want them to be uniformly spaced then use linspace
x = linspace(-100, 100, 10);
If you want them to be uniformlay distributed random numbers then
xLow = -100;
xHigh = 100;
x = rand(1,10);
x = (xHigh - xLow)*x + xLow;