Filter löschen
Filter löschen

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

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

Akzeptierte Antwort

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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by