How to count number from database
Show older comments
I have a database which is a 1x11 struct.

I want to find out the total number present of each countries.
My code is
function [country, count] = movies_by_countries4(TV)
List = arrayfun(@(x) x.country, TV, 'UniformOutput', false);
[Group, country] = findgroups(List');
count = accumarray(Group,1);
end
And it produces result

However, I want to calculate the result for each individual countries.
So the expected result is:
country =
'CA'
'CN'
'US'
count =
1
5
6
what could I do to seperate the last struct and divide it into two individual country.
Accepted Answer
More Answers (0)
Categories
Find more on Database Toolbox 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!