MATLAB: Repeating Matrix Element Until N Times

matrix

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

Best Answer

m=numel(y);
y(mod(0:N-1,m)+1)