image thumbnail
from Summer Olympic Medals 1896-present by Bill McKeeman
Ways of looking at the record of summer olympic medals

getTotalMedals(medals)
% FILE:    getTotalMedals.m
% PURPOSE: how many medals were awarded over all time?
% EXAMPLE:
%    requires allSummers() to make medals(,)
%    meds = getTotalMedals(medals);

function meds = getTotalMedals(medals)
  ol = size(medals,2);                % lastest year we have data
  meds = zeros(1,ol);                 % preallocate
  for i = 1:ol
    rec = medals(:,i);                % pick up medal counts
    meds(i) = sum([rec(:).total]);    % get total, avoid []
  end
end

Contact us at files@mathworks.com