comparison m-toolbox/classes/@ao/conv.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 % CONV vector convolution.
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %
4 % DESCRIPTION: CONV vector convolution.
5 %
6 % CALL: >> c = conv(a,b)
7 %
8 % INPUTS: pl - a parameter list
9 % a,b - input analysis object
10 %
11 % OUTPUTS:
12 % c - output analysis object containing the filtered data.
13 %
14 % <a href="matlab:utils.helper.displayMethodInfo('ao', 'conv')">Parameters Description</a>
15 %
16 % VERSION: $Id: conv.m,v 1.18 2011/04/08 08:56:16 hewitson Exp $
17 %
18 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
19
20 function varargout = conv(varargin)
21
22 % Check if this is a call for parameters
23 if utils.helper.isinfocall(varargin{:})
24 varargout{1} = getInfo(varargin{3});
25 return
26 end
27
28 import utils.const.*
29 utils.helper.msg(msg.PROC3, 'running %s/%s', mfilename('class'), mfilename);
30
31 % Collect input variable names
32 in_names = cell(size(varargin));
33 for ii = 1:nargin,in_names{ii} = inputname(ii);end
34
35 % Collect all AOs and plists
36 [as, ao_invars] = utils.helper.collect_objects(varargin(:), 'ao', in_names);
37
38 if nargout == 0
39 error('### conv cannot be used as a modifier. Please give an output variable.');
40 end
41
42 if numel(as) < 2
43 error('### conv requires at least two input AOs to work.');
44 end
45
46 % Convolute the data
47 name = ao_invars{1};
48 desc = as(1).description;
49 res = as(1).y;
50 plotinfo = as(1).plotinfo;
51 for j=2:numel(as)
52 res = conv(res, as(j).y);
53 name = sprintf('%s,%s', name, ao_invars{j});
54 desc = strcat(desc, [', ' as(j).description]);
55 if ~isempty(as(j).plotinfo)
56 plotinfo = combine(plotinfo, as(j).plotinfo);
57 end
58 end
59
60 % Make new AO
61 bs = ao(res);
62 % name for this object
63 bs.name = sprintf('conv(%s)', name);
64 % set all descriptions
65 bs.description = desc;
66 % keep 'plotinfo'
67 bs.plotinfo = plotinfo;
68 % add history
69 bs.addHistory(getInfo('None'), getDefaultPlist, ao_invars, [as(:).hist]);
70
71 % Set output
72 if nargout == numel(bs)
73 % List of outputs
74 for ii = 1:numel(bs)
75 varargout{ii} = bs(ii);
76 end
77 else
78 % Single output
79 varargout{1} = bs;
80 end
81 end
82
83 %--------------------------------------------------------------------------
84 % Get Info Object
85 %--------------------------------------------------------------------------
86 function ii = getInfo(varargin)
87 if nargin == 1 && strcmpi(varargin{1}, 'None')
88 sets = {};
89 pls = [];
90 else
91 sets = {'Default'};
92 pls = getDefaultPlist;
93 end
94 % Build info object
95 ii = minfo(mfilename, 'ao', 'ltpda', utils.const.categories.sigproc, '$Id: conv.m,v 1.18 2011/04/08 08:56:16 hewitson Exp $', sets, pls);
96 ii.setModifier(false);
97 ii.setArgsmin(2);
98 end
99
100 %--------------------------------------------------------------------------
101 % Get Default Plist
102 %--------------------------------------------------------------------------
103
104 function plout = getDefaultPlist()
105 persistent pl;
106 if exist('pl', 'var')==0 || isempty(pl)
107 pl = buildplist();
108 end
109 plout = pl;
110 end
111
112 function pl_default = buildplist()
113 pl_default = plist.EMPTY_PLIST;
114 end
115