MATLAB Error: Array Indices must be positive or logical values
Mostra commenti meno recenti
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 Commenti
Adam
il 29 Mar 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
il 29 Mar 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
Risposta accettata
Più risposte (1)
Preksha Gupta
il 20 Mag 2022
0 voti
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 Commento
Walter Roberson
il 20 Mag 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.
Categorie
Scopri di più su Loops and Conditional Statements in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!