Term frequency for strings with a given vector
3 ビュー (過去 30 日間)
古いコメントを表示
Hello, I am interested in finding the occurrence of terms with a unique vector already given. Suppose I have the vector
A = {'DI','FI','IM','MI'}
and then another vector B
B = {'MI','IM','MI'}
B is a bi-gram of the name MIMI. I then want to find the occurrence of the terms in B given A, so this would return a vector C
C = [0,0,1,2]
How would I do this in Matlab? Efficiency is also important because I will have to do this for many names. At first I was just using ismember but that was because I didn't have repeating sub-sequences of strings. Thank you in advance!
0 件のコメント
回答 (1 件)
Azzi Abdelmalek
2013 年 6 月 8 日
A = {'DI','FI','IM','MI'}
B = {'MI','IM','MI'}
cellfun(@(x) sum(ismember(B,x)),A)
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Characters and Strings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!