MATLAB Answers

Removing the string from cell array

166 views (last 30 days)
a = {'fdf_faf' ; 'dfaf_dfa' ; 'dfadf_dfaf'; 'dfaf_fdaf';'daf_dfaf';'dfaf_fff'};
index = find(strncmpi(a,'dfaf',4))
index =
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

Accepted Answer

Mischa Kim
Mischa Kim on 1 Jul 2015
Gopalakrishnan, use e.g. strrep
a = {'fdf_faf' ; 'dfaf_dfa' ; 'dfadf_dfaf'; 'dfaf_fdaf';'daf_dfaf';'dfaf_fff'};
arep = strrep(a,'dfaf','')
Gopalakrishnan venkatesan
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 .

Sign in to comment.

More Answers (1)

Stephen on 1 Jul 2015
Edited: Stephen on 1 Jul 2015
>> a = {'fdf_faf'; 'dfaf_dfa'; 'dfadf_dfaf'; 'dfaf_fdaf'; 'daf_dfaf'; 'dfaf_fff'}
a =
>> a(strncmpi(a,'dfaf',4)) = []
a =

Community Treasure Hunt

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

Start Hunting!