home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l460 / 2.ddi / SPARFUN.DI$ / RANDPERM.M < prev    next >
Encoding:
Text File  |  1993-03-07  |  346 b   |  12 lines

  1. function p = randperm(n);
  2. %RANDPERM Random permutation vector.
  3. %    RANDPERM(n) is a random permutation of the integers from 1 to n.
  4. %    For example, RANDPERM(6) might be [2 4 5 6 1 3].
  5. %    
  6. %    Note that RANDPERM calls RAND and therefore changes RAND's
  7. %    seed value.
  8.  
  9. %    Copyright (c) 1984-93 by The MathWorks, Inc.
  10.  
  11. [ans,p] = sort(rand(1,n));
  12.