Randomly combine between 2 vector

4 ビュー (過去 30 日間)
Lila wagou
Lila wagou 2017 年 9 月 13 日
編集済み: Stephen23 2017 年 9 月 13 日
Dear all, how i can combine randomly between 2 vector
V1 = [A B C]
V2 = [1 2 3]
to get for example (C,2), (A,3) and (B,1) As matrix
MV1V2 = C 2
A 3
B 1
  2 件のコメント
Stephen23
Stephen23 2017 年 9 月 13 日
What exactly is
[A B C]
??
Lila wagou
Lila wagou 2017 年 9 月 13 日
編集済み: Lila wagou 2017 年 9 月 13 日
Dear Stephen I replace [A B C] by [10 20 30], I want to get some pair (duo), (30,2), (10,3) and (20,1) As matrix The third in V1 with the second in V2, the first in V1 with the third in V2, the second in V1 with the The first in V2,

サインインしてコメントする。

採用された回答

Stephen23
Stephen23 2017 年 9 月 13 日
編集済み: Stephen23 2017 年 9 月 13 日
To randomly "shuffle" the elements of a vector you can use randperm:
>> V1 = [10;20;30];
>> V2 = [ 1; 2; 3];
>> [V1(randperm(numel(V1))),V2(randperm(numel(V2)))]
ans =
20 3
10 2
30 1

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeGet Started with MATLAB についてさらに検索

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by