How to repeat a cell?
2 次查看(过去 30 天)
显示 更早的评论
I have a cell array and I would like to search for a specific string in the cell array and repeat that cell.
for example my cell array is 111x1 and I want to find 'a' and duplicate it right below the existing one so that the new cell array is 112x1.
0 个评论
采纳的回答
Wayne King
2014-2-28
编辑:Wayne King
2014-2-28
Does it just occur once?
x = {'b','c','d','e','f','a','y','z','h','i','j'};
x = x(:);
y = cell(length(x)+1,1);
idxarray = strcmp(x,'a');
idx = find(idxarray == 1);
y{idx+1} = 'a';
y(1:idx) = x(1:idx);
y(idx+2:end) = x(idx+1:end);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!