Randomize three chosen arrays in matlab

2 ビュー (過去 30 日間)
aboudeh kahaleh
aboudeh kahaleh 2016 年 10 月 13 日
回答済み: Jan 2016 年 10 月 20 日
Hello, On matlab I named A=[0,0,1] B=[0,1,0] C=[1,0,0]
and I want matlab to randomly pick from A B and C how can I do it please ?
In the end I want to display the randomly chosen array?
Please help
  1 件のコメント
Adam
Adam 2016 年 10 月 20 日
I guess you already have 3 answers, but 'randomly pick from A B and C' is not at all a clear definition of what you want. There are numerous different interpretations of what that means!

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

回答 (3 件)

Asad (Mehrzad) Khoddam
Asad (Mehrzad) Khoddam 2016 年 10 月 13 日
m=[A ; B ;C]
m(randi(3),:)
  1 件のコメント
Thorsten
Thorsten 2016 年 10 月 20 日
This picks randomly a column from m, but not randomly from A, B and C.

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


Thorsten
Thorsten 2016 年 10 月 20 日
編集済み: Thorsten 2016 年 10 月 20 日
A = [0,0,1]; B=[0,1,0]; C=[1,0,0];
X = [A; B; C];
x = X(sub2ind(size(X), 1:3, randi(3, [1, 3])))

Jan
Jan 2016 年 10 月 20 日
A=[0,0,1]
B=[0,1,0]
C=[1,0,0]
R = [A(randi(3)), B(randi(3)), C(randi(3))]

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by