Array indices must be positive integers or logical values.

조회 수: 3 (최근 30일)
Kaali Vendan
Kaali Vendan 2020년 5월 31일
댓글: Kaali Vendan 2020년 6월 3일
My code keeps outputting this error:
i = 0;
x1 = xi - f(xi)./df(xi);
while abs(f(x1)) > precision
i = i + 1;
x1 = xi - f(x1)/df(xi)
end
  • Array indices must be positive integers or logical values.
Can anyone suggest a fix?

채택된 답변

madhan ravi
madhan ravi 2020년 5월 31일
f & df should be a function handle , can't see how you defined so it might be the issue.

추가 답변 (1개)

Image Analyst
Image Analyst 2020년 5월 31일
You're passing in x1 and xi as array indexes. These are most likely floating point numbers, not integers or logical values. See the FAQ for a thorough discussion: https://matlab.fandom.com/wiki/FAQ#.22Subscript_indices_must_either_be_real_positive_integers_or_logicals..22

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by