I need to solve this error: Attempted to access CC(:,2); index out of bounds because size(CC)=[9,1].
Show older comments
Hi, I'm starter in Matlab. I have a problem with the error:Attempted to access CC(:,2); index out of bounds because size(CC)=[9,1]. here is the script:
data=load('squat');
ALeft1=data.ALeft1;
AA=zeros(size(ALeft1)); BB=zeros(size(ALeft1)); CC=zeros(size(ALeft1));
delta1=12;
t1=1;
EnergyAveScenario=zeros(length(ALeft1),length(delta1));
for a=t1:1:delta1
EnergyAveScenario(:,a)=f_ET(ALeft1,[80;120],[35;50;60],a);
end
a=zeros(size(EnergyAveScenario(1,:)));
c=zeros(size(EnergyAveScenario(1,:)));
b=zeros(size(EnergyAveScenario(1,:)));
for j=t1:1:delta1
for i=1:1:numel(EnergyAveScenario(:,j))
if EnergyAveScenario(i,j)<=80
AA(i,j)=EnergyAveScenario(i,j);
elseif EnergyAveScenario(i,j)>80 && EnergyAveScenario(i,j)<=120
BB(i,j)=EnergyAveScenario(i,j);
else
CC(i,j)=EnergyAveScenario(i,j);
end
end
end
for j=t1:1:delta1
a(:,j)=numel(find(AA(:,j)~=0));
c(:,j)= numel(find(CC(:,j)~=0));
b(:,j)= numel(find(BB(:,j)~=0));
1 Comment
Geoff Hayes
on 28 May 2014
Please format the above code so that it is readable. See http://www.mathworks.com/matlabcentral/answers/13205-tutorial-how-to-format-your-question-with-markup for details. Or just include the script as an attachment to your question (as the above seems incomplete - missing end for last for loop).
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!