Repeating Matrix Element Until N Times

Excuse me everyone, I want ask that how to repeating the matrix element like this example :
Example: y = [1; 2; 3; 4] and then I want the output like this (for example until N=7) :
Thanks

2 Comments

Matt J
Matt J on 23 Sep 2018
Edited: Matt J on 23 Sep 2018
Why is there a '5' in x but not in y?
Sorry Sir, I have a typo, I Fixed (for Example N=7) :
Thanks

Sign in to comment.

 Accepted Answer

More Answers (1)

Just one of many possible ways...
L=length(y);
N=7;
x=repmat(y,ceil(N/L),1);
x=x(1:N);

Tags

Community Treasure Hunt

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

Start Hunting!