Array indices must be positive integers or logical values.
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Kaali Vendan
le 31 Mai 2020
Commenté : Kaali Vendan
le 3 Juin 2020
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?
0 commentaires
Réponse acceptée
madhan ravi
le 31 Mai 2020
f & df should be a function handle , can't see how you defined so it might be the issue.
Plus de réponses (1)
Image Analyst
le 31 Mai 2020
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
0 commentaires
Voir également
Catégories
En savoir plus sur Matrix Indexing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!