kshuffle.m 569 B

123456789101112131415161718192021
  1. function shuffledArray = kshuffle(inputArray, DIM)
  2. %
  3. % shuffledArray = kshuffle(inputArray, DIM)
  4. %
  5. % Shuffles a matrix by row or column dimension.
  6. %
  7. % Kian Torab
  8. % kian.torab@utah.edu
  9. % Department of Bioengineering
  10. % University of Utah
  11. % Version 1.1.0 - March 4, 2010
  12. switch DIM
  13. case 'row'
  14. shuffledArray = inputArray(randperm(size(inputArray, 1)), :);
  15. case 'column'
  16. shuffledArray = inputArray(:, randperm(size(inputArray, 2)));
  17. otherwise
  18. disp('DIM is invalid. See HELP for more information.');
  19. end