Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function X = gauss(A,b)
- E=[A b]
- n=size(A,1);
- for i=1:1:n-1
- E(i,:) = E(i,:) + E(i+1,:);
- end
- E(n,1)=E(n,1)+E(1,1);
- q=1;
- for i=q:1:n
- for j=1:1:n
- if E(j,i)==0;
- E(j,:)=E(j,:);
- else
- E(j,:)=E(j,:)/E(j,i);
- end
- end
- for k=i+1:1:n
- E(k,:)=E(k,:)-E(i,:);
- end
- q=i+1;
- end
- q=n;
- for i=n:-1:1
- for j=1:1:q
- if E(j,i)==0;
- E(j,:)=E(j,:);
- else
- E(j,:)=E(j,:)/E(j,i);
- end
- end
- for k=1:1:i-1
- E(k,:)=E(k,:)-E(i,:);
- end
- q=q-1;
- end
- X=E(:,n+1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement