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

1 visualizzazione (ultimi 30 giorni)
Is there a way I could generate a row vector (1x 24) that contains the values 1 to 6 repeated exactly 4 times ?

Risposta accettata

infinity
infinity il 22 Giu 2019
Hello,
You can try this
a = 1:6;
b = repmat(a,1,4)
  3 Commenti
infinity
infinity il 22 Giu 2019
Hello,
Then, you can rearrange elements in vector "b" by using this function
c = b(randperm(length(b)));

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by