Removing the string from cell array

97 visualizaciones (últimos 30 días)
Gopalakrishnan venkatesan
Gopalakrishnan venkatesan el 1 de Jul. de 2015
Editada: Stephen23 el 1 de Jul. de 2015
a = {'fdf_faf' ; 'dfaf_dfa' ; 'dfadf_dfaf'; 'dfaf_fdaf';'daf_dfaf';'dfaf_fff'};
index = find(strncmpi(a,'dfaf',4))
index =
2
4
6
so above index string should be removed from cell array
How can i do this using cell fun or some other command?
Thanks a lot

Respuesta aceptada

Mischa Kim
Mischa Kim el 1 de Jul. de 2015
Gopalakrishnan, use e.g. strrep
a = {'fdf_faf' ; 'dfaf_dfa' ; 'dfadf_dfaf'; 'dfaf_fdaf';'daf_dfaf';'dfaf_fff'};
arep = strrep(a,'dfaf','')
  3 comentarios
Mischa Kim
Mischa Kim el 1 de Jul. de 2015
Not quite sure what you mean. Can you elaborate?
Gopalakrishnan venkatesan
Gopalakrishnan venkatesan el 1 de Jul. de 2015
My cell arry will be keep on changing in a loop. For example in the above example i have found the index of matched string right. so using the index found, i need to remove those string in the cell array .

Iniciar sesión para comentar.

Más respuestas (1)

Stephen23
Stephen23 el 1 de Jul. de 2015
Editada: Stephen23 el 1 de Jul. de 2015
>> a = {'fdf_faf'; 'dfaf_dfa'; 'dfadf_dfaf'; 'dfaf_fdaf'; 'daf_dfaf'; 'dfaf_fff'}
a =
'fdf_faf'
'dfaf_dfa'
'dfadf_dfaf'
'dfaf_fdaf'
'daf_dfaf'
'dfaf_fff'
>> a(strncmpi(a,'dfaf',4)) = []
a =
'fdf_faf'
'dfadf_dfaf'
'daf_dfaf'

Categorías

Más información sobre Cell Arrays en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by