You must read in data from two, separate, Excel files. The first file will contain a row of names and is henceforth referred to as the Names File. The second file will contain numeric data and is henceforth referred to as the Scores File. The Scores File will have the same number of columns as the Names File, and a total of 13 rows of numeric data for each column. For instance, if there are two names in the names File, then the Scores File will contain 13 rows by 2 columns of scoring data. Each column in the Scores File represents the 13 weekly scores for the player with the name in the same column in the Names File. Where the A column in the Scores file represents the weekly scores for John. Your job is to write MATLAB to read in the data from the two Excel files, then determine the winner of each week (the player with the highest score), and the winner of the league (the highest score accumulated through all 13 weeks). You will then display to the Command Window, the winner of each week using their names and scores.
So far I have this code:
clc,clear
scores = xlsread('C:\Users\persephone\Desktop\ScoresFile.xlsx'); [num txt raw] = xlsread('C:\Users\persephone\Desktop\NamesFile.xlsx');
plot(scores,'o-') xlabel('Week Number') ylabel('Weekly Score') title('Fantasy Football Scores')
M = max(scores,[],2);
S = sum(scores) W = max(S)
fprintf('The winner for week 1 is name with %d points.\n',M(1)) fprintf('The winner for week 2 is name with %d points.\n',M(2)) fprintf('The winner for week 3 is name with %d points.\n',M(3)) fprintf('The winner for week 4 is name with %d points.\n',M(4)) fprintf('The winner for week 5 is name with %d points.\n',M(5)) fprintf('The winner for week 6 is name with %d points.\n',M(6)) fprintf('The winner for week 7 is name with %d points.\n',M(7)) fprintf('The winner for week 8 is name with %d points.\n',M(8)) fprintf('The winner for week 9 is name with %d points.\n',M(9)) fprintf('The winner for week 10 is name with %d points.\n',M(10)) fprintf('The winner for week 11 is name with %d points.\n',M(11)) fprintf('The winner for week 12 is name with %d points.\n',M(12)) fprintf('The winner for week 13 is name with %d points.\n',M(13)) fprintf('The overall winner is name with %d points.\n',W)
where it says name in the fprintf statements, I need to figure out how to make it say the winner's name.
Best Answer