function NX=rvresize(X, M, N) % rvresize(X, M, N) Resizes the data in the random variable matrix X into % M experiments with N samples each. The new dimensions % must be less than that of the matrix X. s=size(X); if M*N>prod(s) error('new dimesions larger than old dimensions') end NX=zeros(M, N); nr=1; nc=1; or=1; oc=1; while nr<=M NX(nr, nc)=X(or, oc); nc=nc+1; if nc>N nc=1; nr=nr+1; end oc=oc+1; if oc>s(2) oc=1; or=or+1; end end