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 日

0 投票

wordbank(strfind(wordbank,wchoice))

4 件のコメント

NUR KHAIRUNNISA rahimi
NUR KHAIRUNNISA rahimi 2011 年 11 月 28 日
I thought that would work before but matlab gave me this error instead:
??? Error using ==> subsindex
Function 'subsindex' is not defined for values of class 'cell'
NUR KHAIRUNNISA rahimi
NUR KHAIRUNNISA rahimi 2011 年 11 月 28 日
Dear Walter,
is there another way of doing it though?I tried strcmp,and everything that I could with the level I know, but none of it worked out for me.
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 件)

カテゴリ

ヘルプ センター および File 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