I'm solving a system Ax=b with Jacobi. I got it to run through once, but now I need a driver to run 20 iterations of each, while printing the infinity norm of ||t-x^i|| ,where x^i is generated from an initial guess of x0, to a table each iteration.
1 view (last 30 days)
Show older comments
function driver
A = [4 -1 -1 0;-1 4 0 -1;-1 0 4 -1;0 -1 -1 4]';
b = [10.5;-13;1;-1.5];
n = 4;
%% exact solution
t = [2;-3;.5;-1];
x0=[0; 0; 0; 0];
%% updated x vector for infinity norm
x=(1:n);
for i= 1:20
if i = 1
%% initiating jacobi with x0
x = x0;
else x=x(i);
end
Jacobi(A,b,x,n)
%% calculating the infinity norm each iteration
z=norm(t-x(i),inf);
end
end
0 Comments
Answers (0)
See Also
Categories
Find more on Model Verification in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!