An increasing length vector error to find the last component (made through a loop)

조회 수: 3 (최근 30일)
Mahdi
Mahdi 2014년 4월 8일
댓글: the cyclist 2014년 4월 8일
Hello all,
I have created a vector "X" with an initial value for "X1", through a loop, I am adding some other components to this vector. So, at the end of loop: for q=1:n
I should have a vector of length (n+1) for sure. However, for example for n=20, for some runs I have it correct and the vector is made OK. But, some another times that I push the run button (for the same code), I get the following error:
Attempted to access x1(6); index out of bounds because numel(x1)=5. or Attempted to access x1(10); index out of bounds because numel(x1)=9. or....
Do any of you know why? I mean why the result of this code is not consistent?
Regards, Mahdi
  댓글 수: 1
the cyclist
the cyclist 2014년 4월 8일
Can you post the code? It is very difficult for us to guess the problem with out seeing it.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by