How can I repeat the values of an array in the same order?

3 vues (au cours des 30 derniers jours)
Murtada Mohamed
Murtada Mohamed le 21 Déc 2019
Commenté : Murtada Mohamed le 21 Déc 2019
Hello
have an array
W = [ 1 2 3 4 5 ];
I would like it so that I can have a one dimensional array that repeats these falues in the same order an 'n' number of times.
so if i wanted it repeated 3 times my output would be as follows:
W2 = [1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 ];
What is the easiest way to acomplish this?

Réponse acceptée

Stephen23
Stephen23 le 21 Déc 2019
Modifié(e) : Stephen23 le 21 Déc 2019
>> W = [1,2,3,4,5];
>> W2 = repmat(W,1,3)
W2 =
1 2 3 4 5 1 2 3 4 5 1 2 3 4 5

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Produits


Version

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by