⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 perms.m

📁 可用于对信号的频谱进行分析,希望站长能整理好,以便大家互相学习
💻 M
字号:
function P = perms(V)
%PERMS  All possible permutations.
%   PERMS(1:N), or PERMS(V) where V is a vector of length N, creates a
%   matrix with N! rows and N columns containing all possible
%   permutations of the N elements.
%
%   This function is only practical for situations where N is less
%   than about 10 (for N=11, the output takes over 3 giga-bytes).
%
%   Class support for input V:
%      float: double, single
%
%   See also NCHOOSEK, RANDPERM, PERMUTE.

%   Copyright 1984-2004 The MathWorks, Inc.
%   $Revision: 1.12.4.1 $  $Date: 2004/07/05 17:02:07 $

V = V(:).'; % Make sure V is a row vector
n = length(V);
if n <= 1, P = V; return; end

q = perms(1:n-1);  % recursive calls
m = size(q,1);
P = zeros(n*m,n);
P(1:m,:) = [n * ones(m,1) q];

for i = n-1:-1:1,
   t = q;
   t(t == i) = n;
   P((n-i)*m+1:(n-i+1)*m,:) = [i*ones(m,1) t]; % assign the next m
                                               % rows in P.
end

P = V(P);

⌨️ 快捷键说明

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