MATLAB: How do i create random normally distributed number array within a set range

stats

i want to create an array of 2000 values that are within the range [-5 5] and are normally distributed around 0?

Best Answer

Try
sigma = 5;
data = signma * randn(1,2000);
histogram(data)
Since it's normally distributed, some may lie outside your desired range. So adjust the sigma to adjust the proportion of data that you want to be inside the [-5,5] range.