SHARE
TWEET

Untitled

a guest Oct 21st, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function x = GaussFaraPiv( A, b )
  2. %UNTITLED5 Summary of this function goes here
  3. %   Detailed explanation goes here
  4. n = length(b);
  5. A_ext = [A,b];
  6. for k = 1:n-1
  7.     p = find(A_ext(k:n, k)~=0,1,'First');
  8.     if(isempty(p) == 1
  9.         disp('sist este incompatibil/comp nedet');
  10.         x=[];
  11.         return;
  12.     end
  13.     p = p+k-1;
  14.     if p>k
  15.         A_ext([p,k],:)=A_ext([k,p],:);
  16.     end
  17.     for l = k-1:n
  18.         m(l,k) = A_ext(l,k)/A_ext(k,k);
  19.         A_ext(l,:) = A_ext(l,:)-m(l,k)*A_ext(k,:);
  20.     end
  21.     if A_ext(n,n) == 0
  22.         disp('...');
  23.         x=[];
  24.         return;
  25.     end
  26. end
  27. end
  28.  
  29.  
  30.  
  31. %%function x = MetSubstDesc( A, b )
  32. %UNTITLED Summary of this function goes here
  33. %   Detailed explanation goes here
  34. n = length(b); %n = size(A,1), n=size(A,2)
  35. x = zeros(n,1);
  36. x(1) = b(1)/A(1,1);
  37. for k = n-1:1
  38.     %eventual cu suma/for
  39.     %sau:
  40.     x(k) = ( b(k) - A(k,k+1:n)*x(k+1:n) )/A(k,k);
  41. end
  42.  
  43. end
  44.  
  45.  
  46. %%
  47. function x = MetSubstAsc( A, b )
  48. %UNTITLED Summary of this function goes here
  49. %   Detailed explanation goes here
  50. n = length(b); %n = size(A,1), n=size(A,2)
  51. x = zeros(n,1);
  52. x(1) = b(1)/A(1,1);
  53. for k = 2:n
  54.     %eventual cu suma/for
  55.     %sau:
  56.     x(k) = ( b(k) - A(k,1:k-1)*x(1:k-1) )/A(k,k);
  57. end
  58.  
  59. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top