How can I make a vector of a repeating sequence

66 vues (au cours des 30 derniers jours)
Anouk Heuvelmans
Anouk Heuvelmans le 21 Mar 2018
Commenté : Jan le 22 Mar 2018
I want to make a vector with 40 repeats of [0 0 0 1] in a column so it would look like this: 0 0 0 1 0 0 0 1 (0 0 0 1)x40
How would I be able to make this?

Réponse acceptée

Amjad Green
Amjad Green le 21 Mar 2018
x=[0 0 0 1];n=length(x);k=1;j=1; for i=1:40 while j<=n y(k)=x(j); k=k+1; j=j+1; end j=1; end

Plus de réponses (1)

David Fletcher
David Fletcher le 21 Mar 2018
Modifié(e) : David Fletcher le 21 Mar 2018
repmat([0 0 0 1],1,40)
  1 commentaire
Jan
Jan le 22 Mar 2018
This is much more efficient than a loop.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Multidimensional Arrays dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by