Index exceeds the number of array elements (3).

1 回表示 (過去 30 日間)
Amna Awad
Amna Awad 2020 年 11 月 23 日
回答済み: Sindhu Karri 2020 年 11 月 26 日
I'm getting an error with the linspace i have created. im trying to calculate 'TLab'
the error im getting is 'Index exceeds the number of array elements (3).
Error in labmaterials (line 76)
Ms(iii)=2/pi*(w1*log(tan(acos(w1/l_vector(iii)))+l_vector(iii)/w1)+l_vector(iii)*(pi/2)-l_vector(iii)*acos(w1/l_vector(iii)));
this is my code
dpag=linspace(0,3,1000);
for iii =[1:1000]
d=dpag(iii);
Ms(iii)=2/pi*(w1*log(tan(acos(w1/l_vector(iii)))+l_vector(iii)/w1)+l_vector(iii)*(pi/2)-l_vector(iii)*acos(w1/l_vector(iii)));
TLab(iii)=a2*u*b/Ms(iii);
Yield2(iii)=M*Ty1(iii);
end
  1 件のコメント
Nora Khaled
Nora Khaled 2020 年 11 月 23 日
can you share the complete code ?

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

回答 (1 件)

Sindhu Karri
Sindhu Karri 2020 年 11 月 26 日
Hii,
According to my understanding the error 'Index exceeds the number of array elements (3)' is because of using an array (probably l_vector)of size 3 inside for loop which runs 1000 times trying to access out of bound array elements.

カテゴリ

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