Fraction calculation with Text
Show older comments
Hey guys,
i have the following arrays which are saved separately in my Workspace(See below the screenshot). Array A is called "total" in my Workspace and Array B is named "relevant"

I need a code that gives me a table with the fractions:
Number the country is mentioned in Array B / Total number the Country is mentioned in Array A.
So for example: IT appears 2 times in Array B and 7 times in Array A. The fraction is 2/7 = 0.28...
It would be really nice if the fractions are then illustrated in a table in a descending order.
So the final table should look like:

I would really appreciate your help :)
Best Florian
Accepted Answer
More Answers (1)
Image Analyst
on 14 Nov 2015
0 votes
I think you can do this with grpstats() in the Statistics and Machine Learning Toolbox, but I can't try it since you didn't provide any code to generate the arrays. If you don't have that toolbox, try the brute force way with ismember(). You might also need to use unique() and cellfun().
Categories
Find more on Get Started with MATLAB 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!