How to extract info from a cell array using strsplit

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 件のコメント

Xingwang Yong
Xingwang Yong 2020 年 9 月 30 日
It seems you already have these words extracted in your array ep, why do it again?
I assume you want to extract the rows which contain {'ELTOK' , 'HMR' , 'NILUG' , 'XILAN'}, the function contains() is helpful.
Xingwang Yong
Xingwang Yong 2020 年 9 月 30 日
I am still confused about what words you want to extract.
In the orginal question, you said you want to extract words in the array ep= {'ELTOK' , 'HMR' , 'NILUG' , 'XILAN'}, now you said you want to extract 'ESSA', however 'ESSA' is not in the array ep.
Could you please specify the characteristics of the words you want to extract?
It seemed to me you want to extract words that is not lead by the $.
Walter Roberson
Walter Roberson 2020 年 9 月 30 日
Do you always want to exclude works that start with $ or * characters?
What would be an example entry that included HMR (the question being the format for words that are not 5 characters long.)
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 日

0 投票

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);

カテゴリ

ヘルプ センター および File ExchangeCell Arrays についてさらに検索

タグ

質問済み:

2020 年 9 月 30 日

コメント済み:

2020 年 10 月 8 日

Community Treasure Hunt

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

Start Hunting!

Translated by