Effacer les filtres
Effacer les filtres

how to define exactly where the error is

4 vues (au cours des 30 derniers jours)
MAHMOUD ALZIOUD
MAHMOUD ALZIOUD le 31 Déc 2017
Happy new year guys, I have a simple question please, I am writing a code in a for loop and it still gives me an error saying Index exceeds matrix dimensions. and it refers to a line that doesn't have matrix in it ! so seems like this is not the line with the error, how can i please track exactly where the error is?

Réponse acceptée

Walter Roberson
Walter Roberson le 31 Déc 2017
At the command line, try giving the command clear with the function name, like
clear azl_assignment_7
This will remove any copies of the code that it has in memory. This can be needed if you modify code outside of the MATLAB editor, or if you write code files in the program and want to execute the code, or if you had taken the handle of the function in the past.
The only other time I have seen it give the wrong line number was cases where the code had a syntax error, in which case sometimes it gets the wrong line in reporting about the syntax error -- but in such cases the code will not execute at all.
  9 commentaires
MAHMOUD ALZIOUD
MAHMOUD ALZIOUD le 1 Jan 2018
Amazing as usual Mr Walter, thank you very much for your wonderful help. you made sense in many points you mentioned and I will take them into consideration, thank you for the clean up code. and happy new year for you and your blessed family.
MAHMOUD ALZIOUD
MAHMOUD ALZIOUD le 1 Jan 2018
I just tried it and it worked well, Thank you again very much for pointing out the error source, you were right, I added 2 more columns to class 10.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by