Index in position 2 exceeds array bounds

2 ビュー (過去 30 日間)
fawzeya bin tamim
fawzeya bin tamim 2020 年 11 月 24 日
コメント済み: fawzeya bin tamim 2020 年 11 月 24 日
I got this error, what does it mean and how can i fix it?
"Index in position 2 exceeds array bounds (must not exceed 2)."
this is the code of the line:
I(temp,:) = [zeros(1,temp-2) -1/(mul*Capacitance(1,temp-1)) 1/(mul*Capacitance(1,temp-1))+1/(mul*Capacitance(1,temp))+mul*inductance(1,temp) -1/(mul*Capacitance(1,temp)) zeros(1,length(inductance)-1-temp)];
  3 件のコメント
Nora Khaled
Nora Khaled 2020 年 11 月 24 日
Its hard to tell exactly without the rest of the code... but this error happen when you try to access an element in a vector by using wrong indices.
In this case it seems you have a vector with only 2 columns... maybe 'Capacitance' or 'inductance' and temp exceeded 2.
fawzeya bin tamim
fawzeya bin tamim 2020 年 11 月 24 日
Thank you both so much i'll try to work it out

サインインしてコメントする。

回答 (1 件)

Voss
Voss 2020 年 11 月 24 日
This means that the code is attempting to refer to an index of some variable, but the variable is not large enough in that dimension. In this case the dimension is the second dimension ("index in position 2") and the maximum index you can reference is 2 ("(must not exceed 2)").
So basically Capacitance and/or inductance has two columns, but the code is trying to access the third or higher column, which doesn't exist.
  1 件のコメント
fawzeya bin tamim
fawzeya bin tamim 2020 年 11 月 24 日
Thank you so much

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by