MATLAB Answers

selection of n disticnt vector

1 ビュー (過去 30 日間)
parham kianian
parham kianian 2020 年 1 月 19 日
編集済み: John D'Errico 2020 年 1 月 19 日
I have a vector A like
A = 1 : 10
I want to make two distinc vector of length 3 such thta no array be in common between these vectors. for example
a = [1 2 5]
b [ 3 4 8]
is a good answer but somthing like
a = [1 2 5]
b = [5 4 7]
is not desired. Since the number 5 is in common between two vectors.

  0 件のコメント

サインイン to comment.

回答 (1 件)

John D'Errico
John D'Errico 2020 年 1 月 19 日
編集済み: John D'Errico 2020 年 1 月 19 日
Easy enough.
A = 1:10;
index = randperm(10,6);
a = A(index(1:3));
b = A(index(4:6));
Since randperm generates samples without replacement, no overlap is certain.

  0 件のコメント

サインイン to comment.

サインイン してこの質問に回答します。

タグ


Translated by