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
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
2019-5-11
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
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.
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!