MATLAB Error: Array Indices must be positive or logical values
Mostrar comentarios más antiguos
h=input('Enter estimate for root');
f=(h^3)-(9*(h^2))+3.8197;
fprime=(3*(h^2))-(18*h);
for i=1:10
h=h(i)+abs((f(h))/(fprime(h)));
end
2 comentarios
Adam
el 29 de Mzo. de 2019
You either want to create f and fprime as function handles to use the syntax you use, which seems un-necessary here, or just get rid of the (h) from within the for loop:
for i=1:10
h=h(i)+abs(f/fprime);
end
madhan ravi
el 29 de Mzo. de 2019
Shot in the dark:
h=input('Enter estimate for root');
f=@(h)(h^3)-(9*(h^2))+3.8197;
fprime=@(h)(3*(h^2))-(18*h);
for i=1:10
h=h+abs((f(h))/(fprime(h)));
end
Respuesta aceptada
Más respuestas (1)
Preksha Gupta
el 20 de Mayo de 2022
0 votos
load Meter1Cor.txt
XTest= Meter1Cor(:, 2:10);
YTest= Meter1Cor(:,11);
XTest=XTest';
YTest= YTest';
load one
y=one(XTest)
error=y-YTest;
plot(error,'g')
title("Error");
xlabel("Epochs");
ylabel("Error");
This is for testing a trained neural network. "one" is name of trained neural network and i am receiving an error stating that "array indices must be positive intergers or logical values." What could be a possible mistake i made?
1 comentario
Walter Roberson
el 20 de Mayo de 2022
XTest= Meter1Cor(:, 2:10);
That creates a 2d array that would not typically be restricted to positive integers.
load one
y=one(XTest)
You load a variable and then you try to index it using linear indices whose values are the contents of XTest. That requires that XTest either be empty or be all positive integers.
Categorías
Más información sobre Loops and Conditional Statements 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!