Removing the string from cell array

조회 수: 29 (최근 30일)
Gopalakrishnan venkatesan
Gopalakrishnan venkatesan 2015년 7월 1일
편집: Stephen23 2015년 7월 1일
a = {'fdf_faf' ; 'dfaf_dfa' ; 'dfadf_dfaf'; 'dfaf_fdaf';'daf_dfaf';'dfaf_fff'};
index = find(strncmpi(a,'dfaf',4))
index =
2
4
6
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

채택된 답변

Mischa Kim
Mischa Kim 2015년 7월 1일
Gopalakrishnan, use e.g. strrep
a = {'fdf_faf' ; 'dfaf_dfa' ; 'dfadf_dfaf'; 'dfaf_fdaf';'daf_dfaf';'dfaf_fff'};
arep = strrep(a,'dfaf','')
  댓글 수: 3
Mischa Kim
Mischa Kim 2015년 7월 1일
Not quite sure what you mean. Can you elaborate?
Gopalakrishnan venkatesan
Gopalakrishnan venkatesan 2015년 7월 1일
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 .

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Stephen23
Stephen23 2015년 7월 1일
편집: Stephen23 2015년 7월 1일
>> a = {'fdf_faf'; 'dfaf_dfa'; 'dfadf_dfaf'; 'dfaf_fdaf'; 'daf_dfaf'; 'dfaf_fff'}
a =
'fdf_faf'
'dfaf_dfa'
'dfadf_dfaf'
'dfaf_fdaf'
'daf_dfaf'
'dfaf_fff'
>> a(strncmpi(a,'dfaf',4)) = []
a =
'fdf_faf'
'dfadf_dfaf'
'daf_dfaf'

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by