Index exceeds matrix dimensions.

11 visualizaciones (últimos 30 días)
Michael
Michael el 22 de Jul. de 2013
%% Michael Harris % 07/16/2013 % Lab 09
clc
clear all
%% Part 1
% 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);
%% Plot for the Auburn Game Runs Vs. Game attendance for all the games
[h,x1,x2]=plotyy(Games,Aub_Tot_Scores,Games,Attendance);title('Auburn Games
Runs Vs Game Attendance');
set(x1,'linestyle','--');
xlabel('Number of Games');
ylabel('Auburn Runs');
ylabel(h(2),'Attendance');
legend('Auburn','Attendance');
pause(2)

Respuestas (2)

Michael
Michael el 22 de Jul. de 2013
This is what pops up after it says Index exceeds matrix dimensions.
I have tried to manipulate the inputs to make them work but I cant figure it out.
Error in lab09 (line 14)
Both_Team_Scores=Full_Season(2:37,6:25);

Jan
Jan el 22 de Jul. de 2013
Please post a complete copy of the error message and ask a specific question. Posting important information in the answers section is not sufficient, because the readers expect all required details in the question. Therefore you can edit the questions.
If you omit the time-wasting clear all you could use the debugger to find out the reason of the error by your own. Simply set a breakpoint in the offending line or use:
dbstop if error.
Then you can check the actual size of Full_Season and why it has either less columns or rows than you expect.

Categorías

Más información sobre Conway's Game of Life en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by