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

조회 수: 3 (최근 30일)
Arif Najmi 2023년 1월 30일
답변: Askic V 2023년 1월 30일
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?

댓글을 달려면 로그인하십시오.

### 답변 (2개)

Arif Hoq 2023년 1월 30일
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
##### 댓글 수: 0이전 댓글 -2개 표시이전 댓글 -2개 숨기기

댓글을 달려면 로그인하십시오.

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)

댓글을 달려면 로그인하십시오.

### 카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

R2022a

### Community Treasure Hunt

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

Start Hunting!

Translated by