finding parent words using strfind

조회 수: 2 (최근 30일)
NUR KHAIRUNNISA rahimi
NUR KHAIRUNNISA rahimi 2011년 11월 28일
As in normal case, i will have this huge cell array of words,
wordbank={'back'; 'beast';''fairytale';'aerial';'whale';'astronomy'.......}
I asked the user for a string of letters that might compare with what I have in the wordbank, so I tried to use strfind.
say,
wchoice=input('please enter a valid parent word','s')
then from here I tried to compare which word have similarities from the input with the list of words in wordbank.
so I used strfind(wordbank,wchoice)
which later will give me the cell with indices where the words are similar instead of just displaying what the word is.
I was hoping that something like this can appear if
wchoice='al'
I typed strfind(wordbank,wchoice)
ans=
'whale'
'fairytale'
Could you help me with this?Thank you.

채택된 답변

Walter Roberson
Walter Roberson 2011년 11월 28일
wordbank(strfind(wordbank,wchoice))
  댓글 수: 4
Walter Roberson
Walter Roberson 2011년 11월 28일
wordbank(~cellfun('isempty',strfind(wordbank,wchoice)))
NUR KHAIRUNNISA rahimi
NUR KHAIRUNNISA rahimi 2011년 11월 29일
You are awesome!thank you!!!

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

추가 답변 (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