Mercurial > hg > ltpda
comparison m-toolbox/classes/@data3D/applyoperator.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 % APPLYOPERATOR applys the given operator to the two input data objects. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: APPLYOPERATOR applys the given operator to the two input | |
5 % 3D data objects. | |
6 % | |
7 % CALL: d = applyoperator(d1, d2, pl) | |
8 % | |
9 % INPUTS: d1 - a data3D object (xyzdata) | |
10 % d2 - a data3D or cdata object | |
11 % pl - a plist of configuration options | |
12 % | |
13 % PARAMETERS: 'op' - the operator to apply, e.g. 'power' | |
14 % | |
15 % VERSION: $Id: applyoperator.m,v 1.2 2011/02/18 16:48:52 ingo Exp $ | |
16 % | |
17 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
18 | |
19 function varargout = applyoperator(varargin) | |
20 | |
21 % Get the objects we have in the correct order | |
22 objs = varargin(1:2); | |
23 | |
24 % Get the operator to apply | |
25 op = varargin{3}; | |
26 | |
27 if numel(objs) ~= 2 | |
28 error('### data3D/applyoperator requires two input data objects to work on.'); | |
29 end | |
30 | |
31 %--------------- Add some rules here. | |
32 % cdata | |
33 % 1) time-base must match | |
34 % 2) y dimensions must match or one must be a single value | |
35 % | |
36 | |
37 % TODO the rules don't seem to be properly applied here | |
38 | |
39 %%% Decide the type of the output object | |
40 dout = objs{1}; | |
41 | |
42 if isa(objs{2}, 'cdata') | |
43 dout.z = feval(op, objs{1}.z, objs{2}.y); | |
44 else | |
45 dout.z = feval(op, objs{1}.z, objs{2}.z); | |
46 end | |
47 | |
48 varargout{1} = dout; | |
49 end | |
50 |