matlab function randperm () usage

Original link: https://blog.csdn.net/u013476464/article/details/25198071

randperm () function uses
a random function
syntax:

p = randperm (a)
p = randperm (n, k)

Syntax description:

p = randperm (n) Returns the row contains an integer from 1 to n.


>> randperm(6)
 
ans =
 
     2     5     6     4     1     3
 
>> 

p = randperm (n, k) returns a row from 1 to n, k is an integer, and the number k which is not the same.

randperm complete rearrangement is not repeated sampling (k-permutations), if the number of results in the need to repeat the case of multiple occurrences, you can use:

randi (n, 1, k) .
----------------
Disclaimer: This article is CSDN blogger "Zhejiang large-scale machine learning labs - cold tea" original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
Original link: https: //blog.csdn.net/u013476464/article/details/25198071

Guess you like

Origin blog.csdn.net/hhsh49/article/details/100230920