Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function y = gauss(A,B)
- LA = size(A,2);
- [LB1,LB] = size(B);
- L = LA + LB;
- AB = [A(1:LA,1:LA) B(1:LA,1:LB)]; % EPAYKSHMENOS
- for i = 1:LA %sarwnei sthlh katw katw arxika diairei me ton odhgo A(i,i)
- AB(i,i + 1:L) = AB(i,i+1:L)/AB(i,i);
- for x= i + 1: LA %paei sthn epomenh grammh
- 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
- AB(m,k) = 0;%vazw 0 sto stoixeio katw apo ton odhgo
- end
- end
- %VRISKW TIS LYSEIS
- y(LA,:) = AB(LA,LA+1:L)/AB(LA/LA);% vriskw thn pio katw lysh
- for x = LA-1: -1:1 %paw apo katw pros ta panw
- 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
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement