Why do I get "Array indices must be positive integers or logical values" error?

3 visualizaciones (últimos 30 días)
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?

Respuestas (2)

Arif Hoq
Arif Hoq el 30 de En. de 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)
Vc = 1×25
1.0e-04 * -0.1782 -0.1614 -0.1220 -0.0783 -0.0518 -0.0384 -0.0107 0.0362 0.0710 0.0868 0.1066 0.1463 0.1909 0.2132 0.2268 0.2592 0.3043 0.3381 0.3521 0.3732 0.4169 0.4576 0.4786 0.4937 0.5271

Askic V
Askic V el 30 de En. de 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)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by