How to extract info from a cell array using strsplit

5 ビュー (過去 30 日間)
Abdallah Hammad
Abdallah Hammad 2020 年 9 月 30 日
コメント済み: Rena Berman 2020 年 10 月 8 日
ep = {'ELTOK' , 'HMR' , 'NILUG' , 'XILAN'}
How can I use strsplit to extract above words from the first column (cell array) of a table and how to get the count of each word (how many times each word was meantiond in that colounm).
example: I need to exclude all but these specific words 'ELTOK' , 'HMR' , 'NILUG' , 'XILAN' and i want to know the count of each of these words after exctracting.
  5 件のコメント
Walter Roberson
Walter Roberson 2020 年 9 月 30 日
If my answer did not work for you, then please indicate what difficulty you encountered.
Rena Berman
Rena Berman 2020 年 10 月 8 日
(Answers Dev) Restored edit

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

回答 (1 件)

Walter Roberson
Walter Roberson 2020 年 9 月 30 日
targets = {'ELTOK' , 'HMR' , 'NILUG' , 'XILAN'}.';
temp = regexp(text1, '_', 'split');
temp = vertcat(temp{:});
[~, idx] = ismember(temp, targets);
counts = accumarray(idx(:)+1, 1); %words not in list will have idx 0
counts = reshape(counts(2:end),[],1); %first entry counted other words
results = table(targets, counts);

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by