Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function x = GaussFaraPiv( A, b )
- %UNTITLED5 Summary of this function goes here
- % Detailed explanation goes here
- n = length(b);
- A_ext = [A,b];
- for k = 1:n-1
- p = find(A_ext(k:n, k)~=0,1,'First');
- if(isempty(p) == 1
- disp('sist este incompatibil/comp nedet');
- x=[];
- return;
- end
- p = p+k-1;
- if p>k
- A_ext([p,k],:)=A_ext([k,p],:);
- end
- for l = k-1:n
- m(l,k) = A_ext(l,k)/A_ext(k,k);
- A_ext(l,:) = A_ext(l,:)-m(l,k)*A_ext(k,:);
- end
- if A_ext(n,n) == 0
- disp('...');
- x=[];
- return;
- end
- end
- end
- %%function x = MetSubstDesc( A, b )
- %UNTITLED Summary of this function goes here
- % Detailed explanation goes here
- n = length(b); %n = size(A,1), n=size(A,2)
- x = zeros(n,1);
- x(1) = b(1)/A(1,1);
- for k = n-1:1
- %eventual cu suma/for
- %sau:
- x(k) = ( b(k) - A(k,k+1:n)*x(k+1:n) )/A(k,k);
- end
- end
- %%
- function x = MetSubstAsc( A, b )
- %UNTITLED Summary of this function goes here
- % Detailed explanation goes here
- n = length(b); %n = size(A,1), n=size(A,2)
- x = zeros(n,1);
- x(1) = b(1)/A(1,1);
- for k = 2:n
- %eventual cu suma/for
- %sau:
- x(k) = ( b(k) - A(k,1:k-1)*x(1:k-1) )/A(k,k);
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement