creating a row vector containing values between 1 and 6, each repeated exactly 4 times

1 回表示 (過去 30 日間)
Is there a way I could generate a row vector (1x 24) that contains the values 1 to 6 repeated exactly 4 times ?

採用された回答

infinity
infinity 2019 年 6 月 22 日
Hello,
You can try this
a = 1:6;
b = repmat(a,1,4)
  3 件のコメント
infinity
infinity 2019 年 6 月 22 日
Hello,
Then, you can rearrange elements in vector "b" by using this function
c = b(randperm(length(b)));
Yoanna Ivanova
Yoanna Ivanova 2019 年 6 月 22 日
That is exactly it! Thank you!!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by