Effacer les filtres
Effacer les filtres

error: Array indices must be positive integers or logic

2 vues (au cours des 30 derniers jours)
Kayla Garcia
Kayla Garcia le 2 Fév 2024
Commenté : Walter Roberson le 2 Fév 2024
please help

Réponses (2)

VBBV
VBBV le 2 Fév 2024
y(i) = y(i) + 1;
instead of
y(II) = y(II) + 1;
  2 commentaires
VBBV
VBBV le 2 Fév 2024
Modifié(e) : VBBV le 2 Fév 2024
The value of II may be a floatpoint number. MATLAB uses integer and 1 based indexing for accessing array elements
Kayla Garcia
Kayla Garcia le 2 Fév 2024
thank you for the response. i have changed it and it is still giving me the same error message.

Connectez-vous pour commenter.


Walter Roberson
Walter Roberson le 2 Fév 2024
Due to floating point round-off, the result A+(B*x(i)) might not be exactly an integer. You should round() it.
  2 commentaires
Kayla Garcia
Kayla Garcia le 2 Fév 2024
when i try round() i recieve a different message
Walter Roberson
Walter Roberson le 2 Fév 2024
You have not posted enough context to really give you an answer.
But I suspect that you should have made x one element shorter. Something along the line of
x = linspace(xmin, xmax, number_of_steps+1);
x = x(1:end-1);

Connectez-vous pour commenter.

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by