MATLAB: How to use an integer type as first argument to UNIDRND in Statistics Toolbox 7.1 (R2009a)

classdoubleintint32integerstatisticsStatistics and Machine Learning Toolboxunidrnd

I am trying to use an integer variable as the first input argument to the UNIDRND function but receive an error. It is not stated anywhere in the documentation for UNIDRND that N must be of type double. When I execute the following command:
unidrnd(intmax, 1, 2)
I receive the following result:
??? Error using ==> times
Integers can only be combined with integers of the same class, or scalar doubles.
Error in ==> unidrnd at 28
r = ceil(n .* rand(sizeOut));

Best Answer

This change has been incorporated into the documentation in Release 2010a (R2010a). For previous releases, read below for any additional information:
The ability to use an integer type as first argument to the UNIDRND is not available in the Statistics Toolbox 7.1 (R2009a).
To work around this issue, convert the value to a double before invoking the UNIDRND function:
unidrnd(double(intmax), 1, 2)