MATLAB Answers

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

8 ビュー (過去 30 日間)
Ergün AKGÜN
Ergün AKGÜN 2019 年 5 月 11 日
回答済み: Peter Perkins 2019 年 5 月 14 日
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 件のコメント

表示 1 件の古いコメント
Ergün AKGÜN
Ergün AKGÜN 2019 年 5 月 12 日
Hi Madhan,
The second picture in my question is desired output. I did it with copy paste.
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.
Ergün AKGÜN
Ergün AKGÜN 2019 年 5 月 13 日
Hi Image Analyst
I attached the .mat file

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

回答 (2 件)

Sulaymon Eshkabilov
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

  1 件のコメント

Ergün AKGÜN
Ergün AKGÜN 2019 年 5 月 13 日
I attached the .mat file, you can review

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


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.

  0 件のコメント

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

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by