Index exceeds number of array elements (1)?
Mostrar comentarios más antiguos
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)

Respuestas (1)
Cris LaPierre
el 9 de En. de 2021
0 votos
It would appear valores only has a single value, yet you are trying to index a second.
Categorías
Más información sobre Matrix Indexing en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!