You can use randi(imax, size1, size2, size3)where imaxrefers to the maximum values of random numbers (middle upper bound) and 1- lower bound. You can expand the argument sizeto sizeNwhatever you want.
This is an example of its use:
>> A = randi(5, 4, 4, 3)
A(:,:,1) =
4 4 5 4
4 1 2 2
2 1 3 3
4 3 2 4
A(:,:,2) =
5 1 5 1
5 2 2 2
3 5 5 4
1 2 2 3
A(:,:,3) =
2 5 2 3
5 2 3 4
3 4 1 5
3 4 1 1