How to repeat a cell?

2 visualizaciones (últimos 30 días)
andrew
andrew el 28 de Feb. de 2014
Comentada: andrew el 28 de Feb. de 2014
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.

Respuesta aceptada

Wayne King
Wayne King el 28 de Feb. de 2014
Editada: Wayne King el 28 de Feb. de 2014
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);
  1 comentario
andrew
andrew el 28 de Feb. de 2014
How would you duplicate cells 27-50?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Data Type Conversion en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by