How to duplicate cell array by rows?

39 ビュー (過去 30 日間)
Dongyan Zhu
Dongyan Zhu 2021 年 6 月 19 日
回答済み: Scott MacKenzie 2021 年 6 月 19 日
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 Center および File ExchangeLogical についてさらに検索

タグ

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by