Neat implementation... was not able to spin the middle planes, without rotating the entire cube.
Also, the function UNIDRND was missing, so I wrote one:
function r=unidrnd(range,varargin)
% r=unidrnd(range,m,n) - uniform discrete random number generator, 1 to RANGE
r=ceil(rand(varargin{:})*range);