how to crreate an array

3 views (last 30 days)
Awesomer
Awesomer on 5 Nov 2017
Commented: Awesomer on 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

Accepted Answer

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

Sign in to comment.

More Answers (1)

Steven Lord
Steven Lord on 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!