MATLAB: How to generate random integers from the uniform distribution between two numbers

cell arraysfor loopif statementmatrix manipulationrandomrandom number generator

Assume matrix A as follows:
A = [
810 840
840 870
870 900
900 930
930 960
];
For every row in matrix A,I want to generate random integers from the uniform distribution between column 1 and column 2. Also, these random numbers should be divided by 5 with decimal 0 (e.g. 810 (not 811)).
The output matrix size should be 5*1.
I think the right function is randi, but I don't know how to form it.

Best Answer

Under the assumption that you want to include the endpoints, and that the elements of A are evenly divisible by 5:
A = [
810 840
840 870
870 900
900 930
930 960
];
nrows = size(A,1);
r = zeros(nrows,1);
for nr = 1:nrows
r(nr) = 5*randi(A(nr,:)/5);
end