How can I determine the frequency of a text term occurring in a matrix and add this frequency to the matrix?
1 view (last 30 days)
Show older comments
I have a matrix of terms that are unique or multiple and I need to count the frequency of each unique term and add this to the matrix so that I can plot it.
An example of my dataset is below.
'CSARDLSGG##YNEQFF' 'CSARDLRPGGAYNEQFF' 'CSALGGGSTYNEQFF' 'CSALGGGSTYNEQFF' 'CSALGGGSTYNEQFF' 'CSAGVRLAGGVYQETQYF' 'CSAGTRK#NTEAFF' 'CSAGTESNTEAFF' 'CSAGTESNTEAFF' 'CSAGTESNTEAFF' 'CSAGTESNTEAFF' 'CSAGTESNTEAFF' 'CSAGTESNTEAFF' 'CSAGTESNTEAFF'
0 Comments
Answers (2)
Thomas
on 6 Dec 2012
a={'CSARDLSGG##YNEQFF' 'CSARDLRPGGAYNEQFF' 'CSALGGGSTYNEQFF' 'CSALGGGSTYNEQFF' 'CSALGGGSTYNEQFF' 'CSAGVRLAGGVYQETQYF' 'CSAGTRK#NTEAFF' 'CSAGTESNTEAFF' 'CSAGTESNTEAFF' 'CSAGTESNTEAFF' 'CSAGTESNTEAFF' 'CSAGTESNTEAFF' 'CSAGTESNTEAFF' 'CSAGTESNTEAFF'}; % input
out=unique(a); % unique values in a
for ii=1:numel(unique(a))
count(ii)=sum(strcmp(a,out(ii)));
end
unq=out'
count'
0 Comments
See Also
Categories
Find more on Characters and Strings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!