function Astr=dispsysmat(A)
% converts an augmented matrix
% to a string which displays the augmented matrix
% and the associated linear system
% (c) 2013, Bernhard G. Bodmann

[m,n]=size(A);

Astr = "";

% print first system

k=1;
for l=1:1:(n-2)
    Astr=[Astr sprintf("%f x_%i + ",A(k,l),l)];
end
Astr=[Astr  sprintf("%f x_%i = %f     ",A(k,n-1),n-1,A(k,n))];

% measure length

spacer1 = blanks(length(Astr)-13); % minus length of "Linear system"
spacer2 = blanks(length(Astr));


% print matrix

Astr = "";

for l=1:1:n
%printf ("%f x_%i + ",A(k,l),l);
Astr=[Astr  sprintf("%f ",A(k,l))];
end
Astr=[Astr sprintf("|\n")];

spacer3 = blanks(length(Astr)-5);


Astr=["Linear system" spacer1 "\t\t Augmented matrix\n"];

Astr=[Astr  spacer2 "\t\t --" spacer3 "--\n"];

for k=1:1:m
  for l=1:1:(n-2)
     Astr=[Astr  sprintf("%f x_%i + ",A(k,l),l)];
     %printf ("%f x_%i + ",A(k,l),l);
  end
  Astr=[Astr  sprintf("%f x_%i = %f     ",A(k,n-1),n-1,A(k,n))];
  
  Astr=[Astr sprintf("\t\t| ")];
  for l=1:1:n
     %printf ("%f x_%i + ",A(k,l),l);
     Astr=[Astr  sprintf("%f ",A(k,l))];
  end
  Astr=[Astr sprintf("|\n")];
end  
Astr=[Astr  spacer2 "\t\t --" spacer3 "--\n"];

disp(Astr);
