Mercurial > hg > ltpda
comparison m-toolbox/classes/@data3D/applymethod.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 % APPLYMETHOD applys the given method to the input 3D data. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: APPLYMETHOD applys the given method to the input 3D data. | |
5 % | |
6 % CALL: d = applymethod(d, pl) | |
7 % | |
8 % INPUTS: d - a 3D data object (xyzdata) | |
9 % pl - a plist of configuration options | |
10 % | |
11 % PARAMETERS: | |
12 % | |
13 % 'method' - the method to apply to the data | |
14 % 'axis' - which axis vector to apply the method to. Possible values | |
15 % are: 'X', 'Y', 'Z', 'XYZ' [default: 'Z'] | |
16 % 'option' - any additional option to pass to the method. | |
17 % | |
18 % VERSION: $Id: applymethod.m,v 1.3 2011/04/17 09:19:17 hewitson Exp $ | |
19 % | |
20 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
21 | |
22 function pl = applymethod(ds, pl, method, getDefaultPlist, varargin) | |
23 | |
24 % Get function handles | |
25 dxFcn = {}; | |
26 for jj = 1:numel(varargin) | |
27 if isa(varargin{jj}, 'function_handle') | |
28 dxFcn = varargin{jj}; | |
29 end | |
30 if iscell(varargin{jj}) | |
31 list = varargin{jj}; | |
32 if ~isempty(list) && isa(list{1}, 'function_handle') | |
33 dxFcn = list{1}; | |
34 end | |
35 end | |
36 end | |
37 | |
38 pl = applyDefaults(getDefaultPlist('3D'), pl); | |
39 | |
40 % Get the axis we are dealing with | |
41 axis = find(pl, 'axis'); | |
42 % Get the dimension to operate along | |
43 dim = find(pl, 'dim'); | |
44 % Get any additional option | |
45 opt = find(pl, 'option'); | |
46 | |
47 % Loop over data objects | |
48 for jj=1:numel(ds) | |
49 switch lower(axis) | |
50 case 'x' | |
51 ds(jj).x = apply(ds(jj).getX, method, dim, opt); | |
52 case 'y' | |
53 ds(jj).y = apply(ds(jj).y, method, dim, opt); | |
54 case 'z' | |
55 ds(jj).z = apply(ds(jj).z, method, dim, opt); | |
56 case 'xyz' | |
57 ds(jj).x = apply(ds(jj).getX, method, dim, opt); | |
58 ds(jj).y = apply(ds(jj).y, method, dim, opt); | |
59 ds(jj).z = apply(ds(jj).z, method, dim, opt); | |
60 otherwise | |
61 error('### Unknown axis to operate on.'); | |
62 end | |
63 end | |
64 | |
65 end | |
66 | |
67 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
68 % Local Functions % | |
69 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
70 | |
71 %----------------------------------------------- | |
72 % Apply method to the vector v | |
73 %----------------------------------------------- | |
74 function v = apply(v, method, dim, opt) | |
75 if ~isempty(dim) && ~isempty(opt) | |
76 % User supplied a dimension and an option | |
77 v = feval(method, v, dim, opt); | |
78 elseif ~isempty(dim) | |
79 % User supplied only a dimension | |
80 v = feval(method, v, dim); | |
81 elseif ~isempty(opt) | |
82 % User supplied only an option | |
83 v = feval(method, v, opt); | |
84 else | |
85 % User supplied only a method | |
86 v = feval(method, v); | |
87 end | |
88 end | |
89 |