Clear Filters
Clear Filters

how to define exactly where the error is

4 views (last 30 days)
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?

Accepted Answer

Walter Roberson
Walter Roberson on 31 Dec 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 Comments
MAHMOUD ALZIOUD
MAHMOUD ALZIOUD on 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 on 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.

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!