Skip to content

Instantly share code, notes, and snippets.

@ozymandium
Created September 24, 2014 17:23
Show Gist options
  • Save ozymandium/1db20917e566fef8a0c9 to your computer and use it in GitHub Desktop.
Save ozymandium/1db20917e566fef8a0c9 to your computer and use it in GitHub Desktop.
garret's matlab
clear all; close all; clc
% input
%% #1
data = {};
for k = 1:8
[data{k}.num, data{k}.txt, data{k}.raw] = xlsread('RyderCupData.xlsx',k);
end
scores_eur = zeros(12,10,3);
tot_eur = zeros(12,3);
prob_eur = zeros(12,10,3);
probpar = [5 4 3];
for k = 1:3 % for each par
scores_eur(:,:,k) = data{k+1}.num(2:end,2:end);
tot_eur(:,k) = data{k+1}.num(2:end,1);
%tot_usa(:,k) = data{k+4}.num(2:end,1);
fprintf('\nEUR, par-%i\n',probpar(k))
fprintf('Name %i %i %i %i %i %i %i %i %i %i\n',1:10)
for kk = 1:12 % for each player
prob_eur(kk,:,k) = scores_eur(kk,:,k)/tot_eur(kk,k);
prob_eur(kk,:,k) = prob_eur(kk,:,k)/sum(prob_eur(kk,:,k)); % normalize
fprintf('%s: %.4f %.4f %.4f %.4f %.4f %.4f %.4f %.4f %.4f %.4f\n',data{k+1}.txt{kk+1,1},prob_eur(kk,:,k));
end
end
% cross-prob
ryder_par = [4 5 4 3 4 3 4 4 5 3 4 4 4 4 4 5 3 5];
cross_prob = zeros(18,3,12);
for hole_n = 1:18
par_ = ryder_par(hole_n);
par_idx = find(probpar==par_);
for player = 1:12
% win
% get data from
eur = prob_eur(player,:,par_idx);
usa = prob_usa(player,:,par_idx);
% do some comparison here
x = 0;
cross_prob(hole_n, 1, player) = x;
% loss
% do some comparison here
x = 0;
cross_prob(hole_n, 2, player) = x;
% draw
% do some comparison here
x = 0;
cross_prob(hole_n, 3, player) = x;
end
end
for sheet = 1:12
% can add titles/labels
% rows: hole
% columns: win/loss/draw
xlswrite('Output.xlsx', cross_prob(:,:,sheet), sheet)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment