Mercurial > hg > ltpda
diff m-toolbox/classes/@history/string.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/m-toolbox/classes/@history/string.m Wed Nov 23 19:22:13 2011 +0100 @@ -0,0 +1,62 @@ +% STRING writes a command string that can be used to recreate the input history object. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% DESCRIPTION: STRING writes a command string that can be used to recreate the +% input history object. +% +% CALL: cmd = string(history_obj) +% +% INPUT: history_obj - history object +% +% OUTPUT: cmd - command string to create the input object +% +% VERSION: $Id: string.m,v 1.11 2011/02/18 16:48:52 ingo Exp $ +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +function varargout = string(varargin) + + objs = [varargin{:}]; + + cmd = ''; + + for ii = 1:numel(objs) + hh = objs(ii); + m_info = hh.methodInfo; + pl_used = hh.plistUsed; + in_hist = hh.inhists; + + %%% Create minfo string + if isempty(m_info) + minfo_str = '[]'; + else + minfo_str = string(m_info); + end + + %%% Create plist string + if isempty(pl_used) + pl_str = '[]'; + else + pl_str = string(pl_used); + end + + %%% Create history string + if isempty(in_hist) + hi_str = '[]'; + else + hi_str = string(in_hist); + end + if isempty(hi_str) + hi_str = '[]'; + end + + cmd = [cmd 'history(' minfo_str, ', ' pl_str, ', ' hi_str, ') ']; + end + + if numel(objs) > 1 + cmd = ['[ ' cmd ']']; + end + + varargout{1} = cmd; +end +