MATLAB: How to generate decimals in matlab

MATLABrandom number generator

Hi, For an assignment I need to generate 250 numbers between -4 and 5, but I need decimal answers as well. I used an answer from my previous thread, but that only gets whole numbers. I need decimal answers such as 4.2, 2.5, etc. I am currently using x = randi([-4,5], 1,250) Is there a different function i should be using?

Best Answer

a = -4;
b = 5;
r = (b - a) .* rand(1, 250) + a;
Sorry if this solves a homework. I've cited the documentation only.