Index exceeds number of array elements (1)?
Afficher commentaires plus anciens
This is the code on derivada.m:
function [Hd] = derivada(valores, h)
i = 2;
while i < length(valores)
Hd(i) = (valores(i+1) - valores(i-1))/(2 * h);
i = i+1;
end
Hd(1) = ((valores(2) - valores(1))/h);
Hd(length(valores)) = (valores(length(valores)) - valores(length(valores)-1))/h;
end
And this is the main:
valores = y;
h = 0.1;%t(2) - t(1);
Hd = derivada(valores, h);
This is the error:
Index exceeds number of array elements (1)

Réponses (1)
Cris LaPierre
le 9 Jan 2021
0 votes
It would appear valores only has a single value, yet you are trying to index a second.
Catégories
En savoir plus sur Matrix Indexing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!