Index in position 1 exceeds array bounds (must not exceed 1).

1 Ansicht (letzte 30 Tage)
Zair Ahmedi
Zair Ahmedi am 10 Jul. 2019
Beantwortet: Walter Roberson am 16 Jul. 2019
How do I know which line has caused this error?
It is difficult for me to check what has casued the errro if I don't know which line.
  2 Kommentare
Alex Mcaulley
Alex Mcaulley am 10 Jul. 2019
It is shown in the red error text of your Command window
Zair Ahmedi
Zair Ahmedi am 16 Jul. 2019
There is no such a thing

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Walter Roberson
Walter Roberson am 16 Jul. 2019
Give the command
dbstop if error
and run the code. If the place it stops is not a try/catch or error() call, then you have found the line with the problem.
If the place it stops is a try/catch or error() call, then give the command
dbstop if caught error
and run the code again. In some cases you might need to dbcont a few times to get to the correct line.
For example if you were having a problem with the objective function for fmincon then fmincon has try/catch statements to smoothly control for errors, and you would need to use the caught error construct to get to the original line.

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Tags

Produkte


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by