rank keywords using length

11 ビュー (過去 30 日間)
ATHIRA P M
ATHIRA P M 2019 年 3 月 30 日
コメント済み: dpb 2019 年 3 月 31 日
Dear sir,
I rank the keywords firstly according to its occurance.Next the output keywords should be ranked according to its length.how it is possible ?Please help me sir.the code i used is attached below.
fid = fopen('file.txt');
s=textscan(fid,'%s')
fclose(fid);
str=s{:}
[ii,jj,kk]=unique(str)
freq=hist(kk,(1:numel(jj))')'
[ii num2cell(freq)]
output:
'Audrey' [1]
'British' [1]
'Brussels' [1]
'Hepburn' [1]
'Ixelles,' [1]
'actress' [1]
'dancer' [1]
'fashion' [1]
'female' [1]
'film' [1]
'humanitarian' [1]
'icon' [1]
'legend' [1]
'model' [1]
'screen' [1]
'third-greatest' [1]

採用された回答

dpb
dpb 2019 年 3 月 30 日
[~,il]=sort(l,'descend');
K>> s(il)
ans =
16×1 cell array
{'third-greatest'}
{'humanitarian' }
{'Brussels' }
{'Ixelles,' }
{'British' }
{'Hepburn' }
{'actress' }
{'fashion' }
{'Audrey' }
{'dancer' }
{'female' }
{'legend' }
{'screen' }
{'model' }
{'film' }
{'icon' }
K>>
  2 件のコメント
ATHIRA P M
ATHIRA P M 2019 年 3 月 31 日
Dear sir,
it shows an error
undefined function or variable 'l'.
Error in keywords (line 8)
[~,il]=sort(l,'descend');
dpb
dpb 2019 年 3 月 31 日
"l" is the name of the variable holding the list -- I used "l" for the illustration, you need to use whatever it is you have-- "s" above.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by