Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clear
- xdel(winsid())
- //macierz wspolczynnikow
- A = [[1, 1, 1]; [0, -1, 2]; [3, -1, 1]]
- //wektor wynikow
- b = [0; 1; 0]
- //wektor niewiadomych
- x0 = rand(length(b), 1)
- //macierz C
- C = %nan * ones(length(b), length(b))
- //wektor f
- f = %nan * ones(length(b), 1)
- //tworzenie nowych x
- //wypelnanie C i f
- for i = 1:length(b)
- for j = 1:length(b)
- if j == i then
- C(i, j) = 0
- f(i, 1) = b(i, 1)/A(i, i)
- else
- C(i, j) = A(i, j)/A(i, i)
- end
- end
- end
- for n = 1:100
- printf('\nIteracja nr %g', n)
- x = C * x0 + f
- disp(x)
- end
- //iteracja x
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement