how to crreate an array

1 visualizzazione (ultimi 30 giorni)
Awesomer
Awesomer il 5 Nov 2017
Commentato: Awesomer il 5 Nov 2017
lets say i have an array x=[1 0 1] how can i sample every bit 10 times. output will be 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1

Risposta accettata

Star Strider
Star Strider il 5 Nov 2017
Modificato: Star Strider il 5 Nov 2017
Try this:
x=[1 0 1];
N = 10;
Output = reshape(repmat(x(:)', N, 1), 1, [])
  2 Commenti
Awesomer
Awesomer il 5 Nov 2017
It works! Thank you so much.
Star Strider
Star Strider il 5 Nov 2017
As always, my pleasure!

Accedi per commentare.

Più risposte (1)

Steven Lord
Steven Lord il 5 Nov 2017
Use the repelem function.

Community Treasure Hunt

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

Start Hunting!

Translated by