index exceeds matrix dimensions
정보
이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.
이전 댓글 표시
P=0.4;
T=0.5;
a=2;
for i=1:max_it
if x(i)>=0 && x(i)<P %(Error Here)
x(i+1)=x(i)/P;
end
if x(i)>=P && x(i)<=T
x(i+1)=(x(i)-T)/(P-T);
end
if x(i)>=T && x(i)<=1
x(i+1)=a*((x(i)-T)/1-T)*(1-(x(i)-T)/(1-T));
end
% if x(i)>=1-P && x(i)<1
% x(i+1)=(1-x(i))/P;
% end
G(i) =x(i);
end
댓글 수: 0
답변 (2개)
Walter Roberson
2019년 12월 24일
0 개 추천
We do not know what you initialized x as.
You probably did not pre-allocate x; you are probably counting on it growing as you go. However notice that you only ever grow x conditionally: you stop growing x if you encounter an element that is negative or greater than 1.
댓글 수: 0
deepak kumar
2019년 12월 24일
편집: Walter Roberson
2019년 12월 24일
댓글 수: 1
Walter Roberson
2019년 12월 24일
The second x you generate is negative, and as I pointed out before, you stop growing x as soon as you find a negative value.
이 질문은 마감되었습니다.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!