function str = mat2char(mat)
%MAT2CHAR Convert matrix to string.
%
% See also MAT2STR, NUM2STR

% Initial coding by A S Bozin, 6-18-97
% Copyright 1997-2000 The MathWorks, Inc.
% $Revision: 1.4 $ $Date: 2000/06/14 16:12:03 $

   [m,n] = size(mat);
   %
   % Action depends on MAT dimensions
   %
   if (m == 0 | n == 0)
      str = '[]';
   elseif (n == 1)
      if (m == 1)				   % Scalar case
	 str = sprintf('%g',mat);
      else					   % Columnn vector
	 str = cat(2,'[',sprintf('%g;',mat));
	 str(end) = ']';
      end
   else
      %
      % Either a row vector or a matrix
      %
      str = '[';
      for (i = 1:m)
	 str = cat(2,str,sprintf('%g,',mat(i,:)));
	 if (i == m)
	    str(end) = ']';
	 else
	    str(end) = ';';
	 end
      end
   end
   return					   % Last card of MAT2CHAR
