"Subscript indices must either be real positive integers or logicals"
Afficher commentaires plus anciens
Hi,
I'm not sure if this is the right title, but I ran into a problem with my current code.
speed=[1511 1505.7 1490.2 1484.1 1480.3 1481.8 1485.4 1491 1506.3 1524 1548.6];
depth=[0 85 165 295 665 1005 1505 2005 3005 4005 5000];
phi=20;
i=1;
r=0;
while r<4000
n=1;
xn=1;
for i=1:11
c1=speed(1,i);
z1=depth(1,i);
z2=depth(1,i+1);
c2=speed(1,i+1);
a=sind(phi)/c1;
for z=z1:z2
m=(c2-c1)/(z2-z1);
n=c1-m*z1;
cn=m*z+n;
theta=asind(a*cn);
dx=(z-(z+1))*tand(theta);
xn=xn+dx
x(1,n)=abs(xn);
y(1,n)=z;
n=n+1
r=abs(xn);
end
end
phi=phi+5;
end
However, if I run it, I get the error
Subscript indices must either be real positive integers or logicals.
Error in ATOC (line 83)
x(1,n)=abs(xn);
which I don't understand, because n should be a positive integer...
Any ideas? Thank you very much!
Réponse acceptée
Plus de réponses (1)
Anke Kügler
le 31 Oct 2015
0 votes
Catégories
En savoir plus sur Mathematics dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!