How to duplicate cell array by rows?

36 次查看(过去 30 天)
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!

采纳的回答

Scott MacKenzie
Scott MacKenzie 2021-6-19
n = handles.times; % your integer value
newSequence = repmat(sequence, 1, n);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Multidimensional Arrays 的更多信息

标签

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by