Effacer les filtres
Effacer les filtres

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

3 vues (au cours des 30 derniers jours)
Mahdi
Mahdi le 8 Avr 2014
Commenté : the cyclist le 8 Avr 2014
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 commentaire
the cyclist
the cyclist le 8 Avr 2014
Can you post the code? It is very difficult for us to guess the problem with out seeing it.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by