MATLAB: Could anyone help me to fix the issue.

random generation by fixing minimum and maximum value

If A=rand(5,10) how to have the values by fixing the minimum value to be 0.01 and maximum value to be 0.09 and by adding all the random values together it should result in 0.35. For example I have taken the minimum value and maximum value to be 0.01 and 0.09. And the addition of all the values should result in 0.35.Could anyone help me how to implement it.

Best Answer

One way:
a=0.01;b=0.09;N=10;
while true
A=a+(b-a).*rand(N,1)
if ismembertol(sum(A(:)),0.35,1e-2)
break;
else
end
end