Repeating Matrix Element Until N Times

1 visualizzazione (ultimi 30 giorni)
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 Commenti
Matt J
Matt J il 23 Set 2018
Modificato: Matt J il 23 Set 2018
Why is there a '5' in x but not in y?
Dirga Eka Putra L
Dirga Eka Putra L il 23 Set 2018
Modificato: Dirga Eka Putra L il 23 Set 2018
Sorry Sir, I have a typo, I Fixed (for Example N=7) :
Thanks

Accedi per commentare.

Risposta accettata

Matt J
Matt J il 23 Set 2018
m=numel(y);
y(mod(0:N-1,m)+1)

Più risposte (1)

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

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by