필터 지우기
필터 지우기

Matlab Error "Attempted to access -- ; index out of bounds because numel--=???.

조회 수: 1 (최근 30일)
Phoebe
Phoebe 2014년 2월 27일
If my code looks like the following;
time=0; %Initialise time
particleno=9
dt=0.01;
tfinal=40;
diagstep=10;
diagcounter=0;
while time<tfinal
tie=time+dt;
if ((int8(time/diagstep) * diagstep) == int8(time))
[xcounter] = ParticleCounterFun(x0, particleno);
diagcounter=diagcounter+1;
end
Xtcounter(diagcounter)=xcounter(diagcounter);
end %End while time<tfinal LOOP
the FUNCTION FILE FOR PARTICLECOUNTERFUN IS;
function [ xcounter ] = ParticleCounterFun( x0, particleno )
%Initialise counters used in E field diagnostics
counter01=0;
counter12=0;
counter23=0;
counter34=0;
counter45=0;
for np=1:particleno
if (0<=x0(np) & x0(np)<1)
counter01=counter01+1;
end
if (1<=x0(np) & x0(np)<2)
counter12=counter12+1;
end
if (2<=x0(np) & x0(np)<3)
counter23=counter23+1;
end
if (3<=x0(np) & x0(np)<4)
counter34=counter34+1;
end
if (4<=x0(np) & x0(np)<5)
counter45=counter45+1;
end
end
xcounter=[counter01 counter12 counter23 counter34 counter45];
end
Anyway i get this;
>> ParticlePusher Attempted to access xcounter(6); index out of bounds because numel(xcounter)=5.
Error in ParticlePusher (line 101) Xtcounter(diagcounter)=xcounter(diagcounter);
Help please!

답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by