I am getting an error that reads Index exceeds matrix dimensions. Error in lab09 (line 14) Both_Team_​Scores=Ful​l_Season(2​:37,6:25);

6 ビュー (過去 30 日間)
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);

回答 (1 件)

Dishant Arora
Dishant Arora 2013 年 7 月 22 日
use dbstop if error to debug your code, it will give exact location to where your code hangs.
dbstop if error
YourFunction;

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by