Mercurial > hg > ishara
view general/tostring.m @ 4:e44f49929e56
Adding reorganised general toolbox, now in several subdirectories.
author | samer |
---|---|
date | Sat, 12 Jan 2013 19:21:22 +0000 |
parents | |
children | 47cb292350f3 |
line wrap: on
line source
function s=tostring(varargin) % tostring - Tries to represent values as a sensible string % % tostring :: A -> string. % tostring :: A, B -> string. % etc. % % Multiple inputs are converted to comma-separated string. s=cat_sep(',',map(@tostr,varargin)); function s=tostr(x) if ischar(x), s=x; elseif isnumeric(x), sz=size(x); if prod(sz)<16, s=mat2str(x); else s=sprintf('%s[%s]',class(x),mat2str(sz)); end elseif isa(x,'function_handle'), s=func2str(x); if s(1)~='@', s=['@' s]; end elseif isa(x,'func'), s=tostring(x); else s=['obj:' class(x)]; end