function  s = vect2str(V,format)

%VECT2STR -- String representation of a numerical vector.
%
%  S = VECT2STR(V)  converts the vector V into a sting representation S.
%    S is enclosed in square brackets and can be read back by MATLAB to
%    construct an equivalent vector. Matrices are treated as V(:).
%    The default format of each element is '%g'  (see SPRINTF).
%
%  S = VECT2STR(V,FORMAT) uses the format string FORMAT (see SPRINTF).
%
%  Examples:
%    vect2str([1:0.5:3])   ==>  '[1 1.5 2 2.5 3 ]'
%    vect2str([1:0.5:3]')  ==>  '[1 1.5 2 2.5 3 ]''
%    vect2str(magic(3))    ==>  '[8 3 4 1 5 9 6 7 2 ]''
%    vect2str([])          ==>  '[]'
%
%  Deprecation note: This function is redundant in many Matlab versions
%    because the standard mat2str handles vectors quite nicely. It is
%    included here because some of my other utils may use it and because
%    Matlab 5.2 for Mac OS9 does not have mat2str.
%
%  See also MAT2STR, NUM2STR, INT2STR, SPRINTF, SSCANF, EVAL.

% Original coding by Alex Petrov, Ohio State University
% $Revision: 1.1 $  $Date: 2005/03/11 10:20 $
%
% Part of the utils toolbox version 1.1 for MATLAB version 5 and up.
% http://alexpetrov.com/softw/utils/
% Copyright (c) Alexander Petrov 1999-2006, http://alexpetrov.com
% Please read the LICENSE and NO WARRANTY statement in ../utils_license.m

if (nargin==1)  
   format = '%g ' ;
else
   format = [format,' '] ;     % e.g. '%d' becomes '%d '
end

if (size(V,1)<=1)   % row vector or scalar
   s = ['[',sprintf(format,V(:)),']'] ;
else   % column vector (or matrix)
   s = ['[',sprintf(format,V(:)),']'''] ;
end   

%--- Return s
%%%%% End of file VECT2STR.M