Advertisement
KYRALEKOS

ARITHMETIC ANALYSIS my_gauss

Nov 5th, 2019
374
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. function y = gauss(A,B)
  2. LA = size(A,2);
  3. [LB1,LB] = size(B);
  4. L = LA + LB;
  5. AB = [A(1:LA,1:LA) B(1:LA,1:LB)]; % EPAYKSHMENOS
  6. for i = 1:LA %sarwnei sthlh katw katw arxika diairei me ton odhgo A(i,i)
  7. AB(i,i + 1:L) = AB(i,i+1:L)/AB(i,i);
  8. for x= i + 1: LA %paei sthn epomenh grammh
  9. AB(x,i+1:L) = AB(x,i+1:L) - AB(x,i)*AB(i,i+1:L); % pollzw to 1o stoixeio ths grammhs pou vriskomai me thn panw grammh kai to afairw apo thn grammh p vriskomai tr
  10. AB(m,k) = 0;%vazw 0 sto stoixeio katw apo ton odhgo
  11. end
  12. end
  13. %VRISKW TIS LYSEIS
  14. y(LA,:) = AB(LA,LA+1:L)/AB(LA/LA);% vriskw thn pio katw lysh
  15. for x = LA-1: -1:1 %paw apo katw pros ta panw
  16. y(x,:) = AB(x,LA + 1:L)-AB(x,x + 1:LA)*y(x + 1:LA,:)/AB(x,x); % pol/zw to teleutaio stoixeio tou A me thn metavlhth ths grammhs akrivwq apo katw kai thn afairw apo to B
  17. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement