Mercurial > hg > ltpda
diff m-toolbox/classes/@pest/display.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/@pest/display.m Wed Nov 23 19:22:13 2011 +0100 @@ -0,0 +1,133 @@ +% DISPLAY overloads display functionality for pest objects. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% DESCRIPTION: DISPLAY overloads display functionality for pest objects. +% +% CALL: txt = display(pest) +% +% INPUT: pest - pest object +% +% OUTPUT: txt - cell array with strings to display the pest object +% +% <a href="matlab:utils.helper.displayMethodInfo('pest', 'display')">Parameters Description</a> +% +% VERSION: $Id: display.m,v 1.11 2011/04/08 08:56:25 hewitson Exp $ +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +function varargout = display(varargin) + + %%% Check if this is a call for parameters + if utils.helper.isinfocall(varargin{:}) + varargout{1} = getInfo(varargin{3}); + return + end + + objs = utils.helper.collect_objects(varargin(:), 'pest'); + + txt = {}; + + % Print emtpy object + if isempty(objs) + hdr = sprintf('------ %s -------', class(objs)); + ftr(1:length(hdr)) = '-'; + txt = [txt; {hdr}]; + txt = [txt; sprintf('empty-object [%d,%d]',size(objs))]; + txt = [txt; {ftr}]; + end + + for jj=1:numel(objs) + banner = sprintf('---- pest %d ----', jj); + txt = [txt; {banner}]; + + % display + txt = [txt; {sprintf(' name: %s', objs(jj).name)}]; + txt = [txt; {sprintf('param names: %s', utils.helper.val2str(objs(jj).names))}]; + txt = [txt; {sprintf(' y: %s', utils.helper.val2str(objs(jj).y))}]; + txt = [txt; {sprintf(' dy: %s', utils.helper.val2str(objs(jj).dy))}]; + txt = [txt; {sprintf(' yunits: %s', char(objs(jj).yunits))}]; + txt = [txt; {sprintf(' pdf: %s', utils.helper.val2str(objs(jj).pdf))}]; + txt = [txt; {sprintf(' cov: %s', utils.helper.val2str(objs(jj).cov))}]; + txt = [txt; {sprintf(' corr: %s', utils.helper.val2str(objs(jj).corr))}]; + txt = [txt; {sprintf(' chain: %s', utils.helper.val2str(objs(jj).chain))}]; + txt = [txt; {sprintf(' chi2: %s', utils.helper.val2str(objs(jj).chi2))}]; + txt = [txt; {sprintf(' dof: %s', num2str(objs(jj).dof))}]; + txt = [txt; {sprintf(' models: %s', char(objs(jj).models))}]; + txt = [txt; {sprintf('description: %s', objs(jj).description)}]; + txt = [txt; {sprintf(' UUID: %s', objs(jj).UUID)}]; + banner_end(1:length(banner)) = '-'; + txt = [txt; {banner_end}]; + end + + if nargout == 0 + for jj=1:length(txt) + disp(txt{jj}); + end + else + varargout{1} = txt; + end + +end + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Local Functions % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% FUNCTION: getInfo +% +% DESCRIPTION: Get Info Object +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +function ii = getInfo(varargin) + if nargin == 1 && strcmpi(varargin{1}, 'None') + sets = {}; + pl = []; + else + sets = {'Default'}; + pl = getDefaultPlist; + end + % Build info object + ii = minfo(mfilename, 'pest', 'ltpda', utils.const.categories.output, '$Id: display.m,v 1.11 2011/04/08 08:56:25 hewitson Exp $', sets, pl); + ii.setModifier(false); + ii.setOutmin(0); +end + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% FUNCTION: getDefaultPlist +% +% DESCRIPTION: Get Default Plist +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +function plout = getDefaultPlist() + persistent pl; + if exist('pl', 'var')==0 || isempty(pl) + pl = buildplist(); + end + plout = pl; +end + +function plo = buildplist() + plo = plist.EMPTY_PLIST; +end + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% FUNCTION: mat2valstr +% +% DESCRIPTION: Convert a matrix into a string with the maximum size of 40 characters +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +function str = mat2valstr(val) + str = mat2str(val,5); + if numel(str) > 40 + str = [str(1:40), ' ...']; + end +end + +