Repeat elements in an array for certain number of cycles

1 回表示 (過去 30 日間)
mathman
mathman 2017 年 12 月 28 日
回答済み: Sean de Wolski 2017 年 12 月 28 日
I have a 61x1 array, G, I want to make a new array G_2, where the 61 elements of G are repeated for 5 cycles.
For example: G = [1; 2; 3; 4; 5] and G_2 = [1; 2; 3; 4; 5; 1; 2; 3; 4; 5; 1; 2; 3; 4; 5]
I've tried using the repelem function but it repeats the first element twice and then the second element twice and so on giving something like:
G_2 = [1; 1; 2; 2; 3; 3; 4; 4; 5; 5;]

回答 (1 件)

Sean de Wolski
Sean de Wolski 2017 年 12 月 28 日
Repmat instead of repelem.

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by