comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:f0afece42f48
1 % SETOUTPUTS sets the output cell-array for LTPDA methods.
2 %
3 % CALL
4 % out = utils.helper.setoutputs(nout, objs)
5 %
6 % Given the number of output arguments and the array of output objects,
7 % this method does:
8 %
9 % 1) if nout == 1, returns a single cell array of objects
10 % 2) if nout == numel(objs), returns a cell-array with one object per cell
11 % 3) all other cases, it throws an error
12 %
13 % This is intended for use in LTPDA methods like this:
14 %
15 % varargout = utils.helper.setoutputs(nargout, objs)
16 %
17 % M Hewitson 01-04-11
18 %
19 % VERSION: $Id: setoutputs.m,v 1.3 2011/04/11 19:49:51 ingo Exp $
20 %
21
22 function out = setoutputs(nout, bs)
23
24 if nout == 0
25 out = {bs};
26 elseif nout == 1
27 out = {bs};
28 elseif nout == numel(bs)
29 out = cell(size(bs));
30 for ii = 1:numel(bs)
31 out{ii} = bs(ii);
32 end
33 else
34 error('Mismatch between number of ouput objects and output arguments');
35 end
36
37 end