Azzera filtri
Azzera filtri

"Index in position 2 exceeds array bounds. Index must not exceed 1." But which one?

68 visualizzazioni (ultimi 30 giorni)
Hi Everyone,
I'm in the process of implementing a chunk of code from a small test script into a larger code that I've been using. The new chunk of code adds some plots, writes some data, etc.
I'm getting an error that reads "Error using MyFileScriptName. Index in position 2 exceeds array bounds. Index must not exceed 1."
I'm by no means an expert, and I can't find where this error is happening. It does not reference a line in the code or a variable name where the index error is happening?
Anybody have any suggestions on how to troubleshoot this?
  2 Commenti
Walter Roberson
Walter Roberson il 5 Lug 2024 alle 23:32
Do you happen to be compiling the code? Or alternately, do you happen to have pcode'd it? Those could explain the lack of line number.
Meanwhile, give the command
dbstop if error
and execute the code again. It should stop where the problem occurred.
There is a chance you might need to use
dbstop if caught error
Kylen
Kylen il 8 Lug 2024 alle 15:42
Thank you. The "dbstop if error" suggestion helped me identify where my code was erroring out.
And, no, we're not compiling code. Just a small team of engineers trying to run a handful of different Simulink models with a single script. We were running into this error when we combined a few of our Simulink scripts together.
Thanks Again!

Accedi per commentare.

Risposte (0)

Prodotti


Release

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by