Mercurial > hg > ltpda
diff m-toolbox/classes/+utils/@helper/setoutputs.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/+utils/@helper/setoutputs.m Wed Nov 23 19:22:13 2011 +0100 @@ -0,0 +1,37 @@ +% SETOUTPUTS sets the output cell-array for LTPDA methods. +% +% CALL +% out = utils.helper.setoutputs(nout, objs) +% +% Given the number of output arguments and the array of output objects, +% this method does: +% +% 1) if nout == 1, returns a single cell array of objects +% 2) if nout == numel(objs), returns a cell-array with one object per cell +% 3) all other cases, it throws an error +% +% This is intended for use in LTPDA methods like this: +% +% varargout = utils.helper.setoutputs(nargout, objs) +% +% M Hewitson 01-04-11 +% +% VERSION: $Id: setoutputs.m,v 1.3 2011/04/11 19:49:51 ingo Exp $ +% + +function out = setoutputs(nout, bs) + + if nout == 0 + out = {bs}; + elseif nout == 1 + out = {bs}; + elseif nout == numel(bs) + out = cell(size(bs)); + for ii = 1:numel(bs) + out{ii} = bs(ii); + end + else + error('Mismatch between number of ouput objects and output arguments'); + end + +end