Index exceeds the number of array elements (3).

2 次查看(过去 30 天)
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 个)

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 CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by