Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function [x] = gausselim(a,b)
- %GAUSSELIM a on the left, b on the right.
- a = [a b];
- for k = 1:length(a)-2 %Column from 1 to third last
- for i = k+1:length(a)-1 %row from k+1 to second last
- r = a(i,k)/a(k,k);
- for j = k:length(a) %column from k to last, subtraction
- if a(i,j)
- a(i,j) = a(i,j) - a(k,j)*r;
- end
- end
- end
- end
- %Solving phase
- x = zeros(length(a)-1,1);
- for i = length(a)-1:-1:1
- for j = i:length(a)-2
- a(i,end) = a(i,end) - a(i,j+1)*x(j+1);
- end
- x(i) = a(i,end)/a(i,i);
- end
Add Comment
Please, Sign In to add comment