Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- A = [10 2 -1
- -2 -6 -1
- 1 -3 12];
- x = [0 0 0]';
- b = [5 24.42 36];
- G = zeros(3, 3);
- f = zeros(1,3);
- for i = 1:1:length(b)
- for j = 1:1:length(b)
- if i ~= j
- G(i,j) = -A(i,j) / A(i,i);
- end
- end
- f(i) = b(i)/ A(i,i);
- end
- for iter = 1:1:10
- xTemp = x;
- for eq = 1:1:length(b)
- x(eq) = G(eq,:) * x + f(eq);
- %% change "* x" to "* xTemp" to get simple iteration
- %% otherwise it is working as Zeidel Method
- end
- end
- x;
- A * x;
- A = A * A
- L = zeros(3,3);
- for i = 1:1:length(A)
- L(i,i) = sqrt(A(i,i));
- for k = i+1:1:length(A)
- L(k,i) = A(k,i) / L(i,i)
- end
- for j = i+1:1:length(A)
- for k = i:1:length(A)
- L(k,j) = A(k, j) - A(k,i) * A(j,i);
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement