# MATLAB: Solve a system of algebraic equations by Gauss elimination using two significant digits

MATLABmatrix manipulation

Hi, I want to solve a system of algebraic equation by Gauss elimination using to significant digit. I am able to solve this, but I have no idea how to set the matlab to store only two significant digit in each step of calculation.
 function Error1 = gauss3(A,b)   if(size(b,2)>1);      b = b';  end  ExtSol = A\b;                       % This is more efficient than inv(A)*b  n = length(b);  Data1 = [];  % Elimination  for k = 1:n-1      for i = k+1:n          lambda = A(i,k)/A(k,k);          A(i,k:n) = A(i,k:n)-lambda*A(k,k:n);          b(i) = b(i) -lambda*b(k);      end  end  % Back Substitution  x(n) = b(n)/A(n,n);  for k = n-1:-1:1      x(k) = (b(k)-A(k,k+1:n)*x(k+1:n)')/A(k,k);  end  xround = round(x,2,'significant');  Error1 = abs(ExtSol-xround');  Data1 = [Data1; ExtSol x' xround' Error1];  disp('   Exact Sol           Calculated          Rounded             Error')  disp('________________________________________________________________________________')  disp(Data1)  end

defaultNumberOfDigits 2 0
p = hpf(pi)p =3.1e0p*3ans =9.4e0