How to duplicate cell array by rows?
36 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Dongyan Zhu
le 19 Juin 2021
Réponse apportée : Scott MacKenzie
le 19 Juin 2021
I have an 1x3 cell array:
Sequence =
{'3'} {'1'} {'4'}
and a global parameter (integer) named 'handles.times'.
Now I want to realize the following task:
If this integer is 2, then I get the following 'newSequence':
newSequence =
{'3'} {'1'} {'4'} {'3'} {'1'} {'4'}
If this integer is 3, then I get the following 'newSequence':
newSequence =
{'3'} {'1'} {'4'} {'3'} {'1'} {'4'} {'3'} {'1'} {'4'}
and so on...
Does someone know the method? Many thanks!
0 commentaires
Réponse acceptée
Scott MacKenzie
le 19 Juin 2021
n = handles.times; % your integer value
newSequence = repmat(sequence, 1, n);
0 commentaires
Plus de réponses (0)
Voir également
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!