MATLAB Error: Array Indices must be positive or logical values
Ältere Kommentare anzeigen
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 Kommentare
Adam
am 29 Mär. 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
am 29 Mär. 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
Akzeptierte Antwort
Weitere Antworten (1)
Preksha Gupta
am 20 Mai 2022
0 Stimmen
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 Kommentar
Walter Roberson
am 20 Mai 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.
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!