randperm.m

来自「matlab建模工具箱及其应用 功能强大 收藏了很久了 和大家一起分享」· M 代码 · 共 17 行

M
17
字号
function p = randperm(n);
%P=randperm(n) 生成1,2…,n的一个随机排列
%
%RANDPERM Random permutation.
%   RANDPERM(n) is a random permutation of the integers from 1 to n.
%   For example, RANDPERM(6) might be [2 4 5 6 1 3].
%   
%   Note that RANDPERM calls RAND and therefore changes RAND's
%   seed value.
%
%   See also PERMUTE.

%   Copyright (c) 1984-98 by The MathWorks, Inc.
%   $Revision: 5.4 $  $Date: 1997/11/21 23:44:34 $

[ignore,p] = sort(rand(1,n));

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?