Why wont the divide operator work?
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
A = [1 2 1; 2 1 2; 1 2 1];
b = [1; 1; 1];
x = [6; 6; 6];
r = b-a*x;
p = r;
w = zeros(3);
tolerance = 10^(-6);
k = 0;
while norm(r) > tolerance
plot(k,log(norm(r))^2)/(dot(p,A*p));
x = x*p;
r1 = r - a*A*p;
b = (norm(r))^2/((norm(r))^2);
r=r1;
p=r1+b*p;
end
The script is returning an error on the divide operator in the code "plot(k,log(norm(r))^2)/(dot(p,A*p))..." why?
0 Kommentare
Antworten (1)
Mischa Kim
am 28 Nov. 2016
Julia, are you showing all the code? Looks like the variable a is not defined.
As for the plot command: one of the round brackets is misplaced. The way it is typed right now, MATLAB thinks that the command ends after the 2.
plot(k,log(norm(r))^2) /(dot(p,A*p));
0 Kommentare
Siehe auch
Kategorien
Mehr zu Tables finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!