Effacer les filtres
Effacer les filtres

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

68 vues (au cours des 30 derniers jours)
Kylen
Kylen le 5 Juil 2024 à 20:24
Commenté : Kylen le 8 Juil 2024 à 15:42
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 commentaires
Walter Roberson
Walter Roberson le 5 Juil 2024 à 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 le 8 Juil 2024 à 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!

Connectez-vous pour commenter.

Réponses (0)

Catégories

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

Produits


Version

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by