This question is closed. Reopen it to edit or answer.

Can Any One Help im Matrices Comparisons in Matlab!

1 view (last 30 days)
Hello How are you ?
I have a text file named as Final.txt, which consists of words in merged format. These words are from 6 txt files. I wish to compare this Final.txt with each txt file individually and check which words appears how many times.
Like suppose the word small exists in Final.txt file and file named Sports.txt exists. I have calculated words frequencies of Sports.txt individually. Now, I just want to check that how many times this word small appears in Sports.txt file and similarly in other txt files?
I can do it manually but it is taking too much time as words are in lots of ratio.
Thanks a lot
Mazhar Iqbal Rana
Mazhar Iqbal Rana on 6 Jan 2014
Anyway.. My problem is still there please solve if anyone can
Jan on 6 Jan 2014
What exactly is your problem? You describe the goal and write, that you have "made a function". But what is your question then? How can we help you?

Answers (1)

Walter Roberson
Walter Roberson on 7 Jan 2014
Write a routine that, given a file name, finds all the unique words in the file, and their relative frequencies, and returns both the words and their frequencies.
Write a loop over all of the file names, that runs the above routine on the file name, and stores the words and relative frequencies for each file.
Put together all of the word-lists and extract the unique words to find the list of all words used.
Now loop over each word in the list of all words used. For each one, look in each per-file word list to determine whether it existed in that file, and if it did look up the corresponding frequency. Store the counts for each of the files in a table (that is, looping over the per-file information). Continue doing this for each of the words. The end result should be a table of each word and the counts per file.
Now do whatever you are supposed to do with the counts -- printing it out as absolute counts, printing out a table of relative frequencies amongst the files, just indicating which file the word was used the most in, or whatever.

Community Treasure Hunt

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

Start Hunting!