Skip to content

Instantly share code, notes, and snippets.

@drizzd
Created October 7, 2012 16:22
Show Gist options
  • Save drizzd/3848809 to your computer and use it in GitHub Desktop.
Save drizzd/3848809 to your computer and use it in GitHub Desktop.
pretty format matlab variable
function s = repr(x)
% REPR string representation
% s = repr(x)
%
switch class(x)
case 'function_handle'
s = ['@' func2str(x)];
case 'char'
s = ['''' x(:)' ''''];
case { 'logical', 'double', 'single' }
s = mat2str(x);
otherwise
error(['cannot convert class ''', class(x) , ''' to string']);
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment