replace the string a cell array with empty cell

2 Ansichten (letzte 30 Tage)
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

Akzeptierte Antwort

Nobel Mondal
Nobel Mondal am 7 Mai 2015
You may directly use the strrep function
a = strrep(a, 'def', '');
  2 Kommentare
Iason Grigoratos
Iason Grigoratos am 21 Dez. 2016
how can I do it for a 2D array? strrep return 1D cell array

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Characters and Strings finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by