필터 지우기
필터 지우기

Find the index of a string is structure

조회 수: 3 (최근 30일)
Eliah Verbeemen
Eliah Verbeemen 2018년 4월 6일
편집: Eliah Verbeemen 2018년 4월 9일
How can you find the index of the cell with the word dranken in a strucurearray with the fields data and textdata? I know that the word always is goind to be in the field textdata.
Thank you

채택된 답변

Sergey Kasyanov
Sergey Kasyanov 2018년 4월 6일
편집: Sergey Kasyanov 2018년 4월 6일
As i understand you right, the field textdata contains cell array with some strings. Let figure that A - structure. Then if you looking for exact coincidence try this:
NumberOfCell=find(cellfun(@strcmp,A.textdata,repmat({'word'},size(A.textdata)))==1)
If textdata contain strings where you want find one word then try this:
NumberOfCell=cell2mat(cellfun(@strfind,A.textdata,repmat({'word'},size(A.textdata)),'UniformOutput',false))
  댓글 수: 1
Sergey Kasyanov
Sergey Kasyanov 2018년 4월 6일
편집: Sergey Kasyanov 2018년 4월 6일
Sorry. There is mistype.
NumberOfCell=find(cellfun(@strcmp,A.textdata,repmat({'word'},size(A.textdata)))==1)

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Characters and Strings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by