perms
所有可能的排列
说明
示例
v = uint16([1023 4095 65535]); P = perms(v)
P = 6×3 uint16 matrix
65535 4095 1023
65535 1023 4095
4095 65535 1023
4095 1023 65535
1023 65535 4095
1023 4095 65535
v = [1+1i 2+1i 3+1i]; P = perms(v)
P = 6×3 complex
3.0000 + 1.0000i 2.0000 + 1.0000i 1.0000 + 1.0000i
3.0000 + 1.0000i 1.0000 + 1.0000i 2.0000 + 1.0000i
2.0000 + 1.0000i 3.0000 + 1.0000i 1.0000 + 1.0000i
2.0000 + 1.0000i 1.0000 + 1.0000i 3.0000 + 1.0000i
1.0000 + 1.0000i 3.0000 + 1.0000i 2.0000 + 1.0000i
1.0000 + 1.0000i 2.0000 + 1.0000i 3.0000 + 1.0000i
输入参数
项目集合,指定为数值、logical 或 char 值的向量。
示例: [1 2 3 4]
示例: [1+1i 2+1i 3+1i 4+1i]
示例: int16([1 2 3 4])
示例: ['abcd']
示例: [true false true false]
数据类型: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical | char
复数支持: 是
限制
当 length(v) 大约小于 10 时,perms(v) 较实用。
详细信息
集合的排列是集合元素的所有可能的排列。P = perms(v) 以 v 中元素索引的字典编纂逆序返回向量 v 的元素排列。例如,对于具有 3 个元素的向量 v,P = perms(v) 返回的输出与以下内容相同:
P = [v(3) v(2) v(1);
v(3) v(1) v(2);
v(2) v(3) v(1);
v(2) v(1) v(3);
v(1) v(3) v(2);
v(1) v(2) v(3)]扩展功能
C/C++ 代码生成
使用 MATLAB® Coder™ 生成 C 代码和 C++ 代码。 (自 R2024b 起)
此函数完全支持基于线程的环境。有关详细信息,请参阅在基于线程的环境中运行 MATLAB 函数。
perms 函数完全支持 GPU 数组。要在 GPU 上运行该函数,请将输入数据指定为 gpuArray (Parallel Computing Toolbox)。有关详细信息,请参阅在 GPU 上运行 MATLAB 函数 (Parallel Computing Toolbox)。
此函数完全支持分布式数组。有关详细信息,请参阅使用分布式数组运行 MATLAB 函数 (Parallel Computing Toolbox)。
版本历史记录
在 R2006a 之前推出
另请参阅
nchoosek | permute | randperm | combinations
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)