npermutek软件

permutes k elements from the vector v

软件应用简介

npermutek软件

permutes k elements from the vector v

NPERMUTEK – permutations without repetitions.

This function A = npermutek(v,k) returns all the possible permutations

of k elements from the vector v without repetitions. k should be less than

or equal to number of elements in v.

The function [A, I] = npermutek(v,k) returns both the matrix and indeces

of the permuted matrix, such that A = v(I). Both matrices will be of the

size nPk-by-k where k = numel(v).

Examples:

v = 1:4;

k = 3;

A = npermutek(v,k); % returns 24-by-3 matrix

1 2 3

1 2 4

1 3 2

1 3 4

1 4 2

1 4 3

2 1 3

2 1 4

2 3 1

2 3 4

2 4 1

2 4 3

3 1 2

3 1 4

3 2 1

3 2 4

3 4 1

3 4 2

4 1 2

4 1 3

4 2 1

4 2 3

4 3 1

4 3 2

v = ‘abc’;

k = 2;

[A,I] = npermutek(v,k) % returns 6-by-2 char array

‘ab’

‘ac’

‘ba’

‘bc’

‘ca’

‘cb’

and 6-by-2 matrix

1 2

1 3

2 1

2 3

3 1

3 2

界面展示

npermutek软件

结果示意

npermutek软件

规格 价

0元试用
0.0元人民币/月

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2022年4月25日
下一篇 2022年4月25日

相关推荐