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

4 次查看(过去 30 天)
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 个评论
Walter Roberson
Walter Roberson 2024-7-5
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 2024-7-8
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!

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by