I am getting an error that reads Index exceeds matrix dimensions. Error in lab09 (line 14) Both_Team_Scores=Full_Season(2:37,6:25);
Afficher commentaires plus anciens
I am getting an error that reads Index exceeds matrix dimensions. Error in lab09 (line 14) Both_Team_Scores=Full_Season(2:37,6:25);
If anyone knows how to fix this problem please let me know. I have tried to manipulate the input for the Line of code in question but I can not figure it out.
*Below is the section of code that has the Error in it. *
% Inputs of the data to be able to run the code
Full_Season=xlsread('data09.xls');
Both_Team_Scores=Full_Season(2:37,6:25);
Both_Team_Scores(isnan(Both_Team_Scores))=0;
Auburn=Both_Team_Scores(:,11:20);
Opponents=Both_Team_Scores(:,1:10);
Attendance=Full_Season(2:37,2);
Games=(1:36)';
%% Scores of the Games for auburn and the opponents
Aub_Tot_Scores=sum(Auburn,2);
Opp_Tot_Scores=sum(Opponents,2);
Margin_Wins=find(Aub_Tot_Scores>Opp_Tot_Scores);
Wins=numel(Margin_Wins);
Margin_Losses=find(Opp_Tot_Scores>Aub_Tot_Scores);
Losses=numel(Margin_Losses);
Winning_Amount=(Aub_Tot_Scores-Opp_Tot_Scores);
Winning_Spread=max(Winning_Amount);
Loosing_Amount=(Opp_Tot_Scores-Aub_Tot_Scores);
Loosing_Spread=max(Loosing_Amount);
%% Recording the Data so the user will be able to see
fprintf('Season Stats as of %d/%d/%d\n',[4,8,2012])
fprintf('Auburns season record: %d-%d\n',[Wins, Losses]);
fprintf('Largest Spread for Wins:%d\n',Winning_Spread);
fprintf('Largest Spread for Loss:%d\n',Loosing_Spread);
Réponses (1)
Dishant Arora
le 22 Juil 2013
use dbstop if error to debug your code, it will give exact location to where your code hangs.
dbstop if error
YourFunction;
Catégories
En savoir plus sur Matrix Indexing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!