Index exceeds the number of array elements (3).

2 Ansichten (letzte 30 Tage)
Amna Awad
Amna Awad am 23 Nov. 2020
Beantwortet: Sindhu Karri am 26 Nov. 2020
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

Antworten (1)

Sindhu Karri
Sindhu Karri am 26 Nov. 2020
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.

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by