Index in position 2 exceeds array bounds (must not exceed 3).

1 visualización (últimos 30 días)
Kashfia Mahin
Kashfia Mahin el 24 de Ag. de 2019
Editada: KALYAN ACHARJYA el 24 de Ag. de 2019
%% l2/l1=1
N=1; %revolution per minute
theta=28 %dynamic angle of glass beads
w=2*pi*N/60; % angular velocity
D=.5; %drum radius
R=D/2; %drum diameter
g=9.81; %gravity
l1=.05; %radial length in flight
a=0:.5:1;
l2=a.*l1;
%l2=.05; %tangential length in flight
beta=atand(l2./l1);
flight_length_ratio=l2./l1;
rh=R-l1; %distance from the centre to the radial length
meu=tand(theta);%friction of coefficient
alpha=atand(l2./rh); %flight angle
%%
froude= .0011; %foude number
delta=-90:30:270; %discharge angle
e=0;
f=0;
for u=1:length(a)
e=e+1;
for v=1:length(delta)
f=f+1;
nominator(e,f)=meu*cosd(alpha(e,f))+froude*rh/R*(cosd(delta(e,f))-meu*sind(delta(e,f)));
end
end
nominator_1(1,f)=nominator(e,f);
Error in filling_degree_try (line 28)
nominator(e,f)=meu*cosd(alpha(e,f))+froude*rh/R*(cosd(delta(e,f))-meu*sind(delta(e,f)));
I can't figure it out the error. plz help me to figure it out.

Respuestas (1)

KALYAN ACHARJYA
KALYAN ACHARJYA el 24 de Ag. de 2019
Editada: KALYAN ACHARJYA el 24 de Ag. de 2019
>> length(a)
ans =
3
>> length(delta)
ans =
13
>> size alpha
ans =
1 5
Both alpha and delta have 1x5 size, how can you acess the same data with with e and f, where e ranges from 1 to 5, OK no issue, but f ranges from 1 to 25, issue with f value??
See the e and f data
f=0;
e=0;
for u=1:5
e=e+1
for v=1:5
f=f+1
end
end
Result:
e =
1
f =
1
f =
2
f =
3
f =
4
f =
5
e =
2
f =
6
f =
7
f =
8
f =
9
f =
10
e =
3
f =
11
f =
12
f =
13
f =
14
f =
15
e =
4
f =
16
f =
17
f =
18
f =
19
f =
20
e =
5
f =
21
f =
22
f =
23
f =
24
f =
25
>>
You are trying to acess the data, which does not have like alpha(1,10), delta(3,24) etc.....
In your case the allowable indexing case for alpha or delta(1, maximum 5), hence you cant do that double for iteration loop in this case. The alpha(1,some value) or delta(1,some value), here some value ranges from 1 to 5 only.

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by