How do I find , using a table (of football results), how many time the home team has won to the nearest percent??
2 views (last 30 days)
Show older comments
alex thomson
on 19 Oct 2015
Answered: Image Analyst
on 19 Oct 2015
>> tab(1,:) ans = 1 4 2001 30 29 8 1
Column meaning example comments
- day of month 1
- month of year 4 (April)
- year 2001 (so, date was 1st April 2001)
- home team 30 (number of team)
- guest team 29 (number of team)
- goals of home team 8
- goals of guest team 1
In short, tab(1,:) states that on 1st April 2001, team 30 won at home
0 Comments
Accepted Answer
Image Analyst
on 19 Oct 2015
Is "tab" a matrix of doubles, or a table?
See a very similar question I just answered: http://www.mathworks.com/matlabcentral/answers/248034-finding-how-many-times-a-team-lost-from-an-array#answer_195544
To get the home team wins and losses, you can extract columns 6 and 7, then compare, sum, and round to the nearest integer:
percentHomeWins = round(100 * sum(tab(:,6)>tab(:,7)) / size(tab, 1));
This doesn't take into account the number of wins "by team number" like my other answer.
0 Comments
More Answers (0)
See Also
Categories
Find more on Startup and Shutdown 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!