How to find same values in table and show them in a new table?

7 次查看(过去 30 天)
Hi all
I have 50x30 Table name 'TToplam', 1st column contain word (Word2004), 2nd count of the word (Count2004) and this two columns represent a year. There are total 15 years data.
I want to show similarities and diversities of words.
Problem 1: How can i find similar (exactly word have to be all years) words from 1st,3rd,5th....15th column and match them with their counts in a new Table?
Example
Problem 2: How can i find diversities (Unique ones) of words in a new Table?
  4 个评论
Image Analyst
Image Analyst 2019-5-12
Can you attach the table in a .mat file witht he paper clip icon? This will make it easier for us to try code with it.

请先登录,再进行评论。

回答(2 个)

Sulaymon Eshkabilov
One of the possible ways is to write a small function file with fgetl(), ischar(), strfind(), etc., like this one. This can search for specific words in your data file, e.g. MY_table.csv
function W=wordsearch_ALL(myfilename, WordSpell)
% The script reads and searches for keywords.
% e.g.: >> W = wordsearch_ALL('MY_table.csv', 'student')
fid=fopen(myfilename);
w=0;
wholeline=fgetl(fid);
while ischar(wholeline)
match_found=strfind(wholeline, WordSpell);
num=max(size(match_found));
if num>0
w=w+num;
fprintf(1, '%d:%s\n', num, wholeline);
end
wholeline=fgetl(fid);
end
fclose(fid);
Good luck

Peter Perkins
Peter Perkins 2019-5-14
Your first question is just an inner join, I think. Perhaps an outer join, you have not explained sufficiently. You'll have to split the one table into 15 tables though.
Not sure I understand what the second question means. Maybe you want to vertically concatenate those 15 tables and cal unique on the (one) Word variable? You'll need to make the (two) variable names match in all 15 to vertcat them.

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by