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

0 Stimmen

You may directly use the strrep function
a = strrep(a, 'def', '');

2 Kommentare

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 Hilfe-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