replace the string a cell array with empty cell

2 vues (au cours des 30 derniers jours)
Gopalakrishnan venkatesan
Commenté : Iason Grigoratos le 21 Déc 2016
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

Réponse acceptée

Nobel Mondal
Nobel Mondal le 7 Mai 2015
You may directly use the strrep function
a = strrep(a, 'def', '');
  2 commentaires
Gopalakrishnan venkatesan
Thanks
Iason Grigoratos
Iason Grigoratos le 21 Déc 2016
how can I do it for a 2D array? strrep return 1D cell array

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Characters and Strings dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by