MATLAB: How to count number of words in a text file

datastringText Analytics Toolboxtextscanvariableword count

I have a text file with a large number of words, 'filename.txt'.
I have a column of words 'A'.
Example:
A =
HJK.BT
KLP.OK
POL.ST
I want to go through column A and count how many times each of the words in column A appears in the text file. How can I do this? I tried 'textscan' but have had no luck.
Basically, I want to end up with something like:
Column A # of Times Occurred
HJK.BT 3
KLP.OK 4
POL.ST 2

Best Answer

A={'HJK.BT'
'KLP.OK'
'HJK.BT'
'POL.ST'
'HJK.BT'
'POL.ST'}
[ii,jj,kk]=unique(A)
freq=accumarray(kk,1)
out=[ii num2cell(freq)]