Mercurial > hg > ishara
view general/tostring.m @ 61:eff6bddf82e3 tip
Finally implemented perceptual brightness thing.
author | samer |
---|---|
date | Sun, 11 Oct 2015 10:20:42 +0100 |
parents | ae596261e75f |
children |
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=catsep(',',map(@tostr,varargin)); end function s=tostr(x) if ischar(x), s=x; elseif isnumeric(x), sz=size(x); if prod(sz)<16, s=mat2str(x,5); 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 end