Why wont the divide operator work?
조회 수: 10 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Mischa Kim
2016년 11월 28일
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
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!