How do I count the number of each particular entry in a variable
5 views (last 30 days)
Show older comments
I have a list of words stored as a variable on matlab and I need to be able to 'pickout' and count the different words. I know you can do that using the strfind function. However it is in a column not a row (Input strings must have one row.)So my question is how do you fix this, or is there a better way to pick out and out the words. An example of my problem
I have stored in my workspace the variable "countries"
val=
AUS
CAD
USA
USA
...
now i need to be able to count the number of each occurrence of the countries like 2 USA 1 AUS 1 CAD etc
Thanks
0 Comments
Accepted Answer
Azzi Abdelmalek
on 23 Mar 2013
2 Comments
Azzi Abdelmalek
on 24 Mar 2013
Edited: Azzi Abdelmalek
on 24 Mar 2013
country={'abc';'def';'ghi'} %to create a cell array
% to an element to your cell array
country{4}='jkl'
More Answers (0)
See Also
Categories
Find more on Model Import 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!