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

 Réponse acceptée

Star Strider
Star Strider le 5 Nov 2017
Modifié(e) : Star Strider le 5 Nov 2017

0 votes

Try this:
x=[1 0 1];
N = 10;
Output = reshape(repmat(x(:)', N, 1), 1, [])

2 commentaires

Awesomer
Awesomer le 5 Nov 2017
It works! Thank you so much.
Star Strider
Star Strider le 5 Nov 2017
As always, my pleasure!

Connectez-vous pour commenter.

Plus de réponses (1)

Steven Lord
Steven Lord le 5 Nov 2017

0 votes

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