フィルターのクリア

How do you use randperm on a vector?

9 ビュー (過去 30 日間)
lauuser1
lauuser1 2016 年 2 月 14 日
コメント済み: Guillaume 2016 年 2 月 14 日
I have a vector
A = repmat(1:6, [1 4])
and I need to use randperm to randomize it. How would I do that?

採用された回答

Kristi
Kristi 2016 年 2 月 14 日
A = repmat(1:6, [1 4])
B = A(randperm(24))
  1 件のコメント
Guillaume
Guillaume 2016 年 2 月 14 日
B = A(randperm(numel(A))
would be a lot better since it will work regardless of the size of A. As a rule avoid hardcoded constants, particularly as it's trivial to obtain the number of elements in A.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStructures についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by