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

조회 수: 2,224 (최근 30일)
Why do I get "Array indices must be positive integers or logical values" error when using "angle" function?
>> z = 22+i
>> a = angle(z)
>> z =
22.0000 + 1.0000i
ERROR: Array indices must be positive integers or logical values.

채택된 답변

MathWorks Support Team
MathWorks Support Team 2023년 8월 22일
편집: MathWorks Support Team 2021년 5월 20일
Based on the error message, it seems like you have a variable with the name "angle" stored in your workspace that overshadows the "angle" function
  댓글 수: 4
Walter Roberson
Walter Roberson 2022년 4월 28일
That code assumes that the values in Scores and Scores2 are all positive integers, and will give you an error if that is not the case.
That code also assumes that the Scores and Scores2 values are all either 1 or 2, but will not give an error if they are larger integers instead.
DGM
DGM 2022년 5월 10일
편집: DGM 2022년 5월 10일
@Nguyen Quoc Khanh: t is not a nonzero integer. It can't be used for an index on the LHS of that assignment. You don't need to anyway.
s = cos(2*pi*100*t) + 2*cos(2*pi*200*t+pi/2) + 3*cos(2*pi*200*t+pi/4); % quá trình lấy mẫu

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by