Why do I get "Array indices must be positive integers or logical values" error?
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
lc= 0.03
b=0.013
Rc= 0.0275
theta1= 0:15:360
theta2=theta1*pi/180
x=lc/2;
y=((Rc^2)*(theta2))
z=((b^2)*0.5)*(sin((theta1).*2))
r=b*(sin(theta1))
u1=Rc^2
u2=r.^2
u=r.*(((u1)-(u2)).^1/2)
rr=Rc^2*atan(r/u)
Vc=x(y+z-u-rr)
Why can't solve? Can someone help me?
0 Commenti
Risposte (2)
Arif Hoq
il 30 Gen 2023
try this:
lc= 0.03;
b=0.013;
Rc= 0.0275;
theta1= 0:15:360;
theta2=theta1*pi/180;
x=lc/2;
y=((Rc^2)*(theta2));
z=((b^2)*0.5)*(sin((theta1).*2));
r=b*(sin(theta1));
u1=Rc^2;
u2=r.^2;
u=r.*(((u1)-(u2)).^1/2);
rr=Rc^2*atan(r/u);
Vc=x*(y+z-u-rr)
0 Commenti
Askic V
il 30 Gen 2023
You asked why, and the answer is because of this line:
Vc=x(y+z-u-rr)
here, x is considered an array and y+z-u-rr is an index. basically you're trying to access an element of the array throught its index. Indices should be positive integers or logical values and not numbers with decimal points.
So this is probably a typo and Arif corrected this line to be:
Vc=x*(y+z-u-rr)
0 Commenti
Vedere anche
Categorie
Scopri di più su Matrix Indexing in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!