replace the string a cell array with empty cell

I have a cell array a = {'abc' ; 'def' ; 'ghi' ; 'def' ; 'xyz'}
I need to replace a 'def' with empty cell.
so my answer should be a = {'abc' ; '' ; 'ghi' ; '' ; 'xyz'}
How can i do this using cell function?
thank you

 Respuesta aceptada

Nobel Mondal
Nobel Mondal el 7 de Mayo de 2015
You may directly use the strrep function
a = strrep(a, 'def', '');

2 comentarios

how can I do it for a 2D array? strrep return 1D cell array

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Characters and Strings en Centro de ayuda y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by