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)
>> tab(1,:) 
ans = 1 4 2001 30 29 8 1 

Column meaning example comments

  1. day of month 1
  2. month of year 4 (April)
  3. year 2001 (so, date was 1st April 2001)
  4. home team 30 (number of team)
  5. guest team 29 (number of team)
  6. goals of home team 8
  7. goals of guest team 1

In short, tab(1,:) states that on 1st April 2001, team 30 won at home

Accepted Answer

Image Analyst
Image Analyst on 19 Oct 2015
Is "tab" a matrix of doubles, or a table?
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.

More Answers (0)

Categories

Find more on Startup and Shutdown in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!