Mercurial > hg > ltpda
comparison m-toolbox/classes/@ao/hypot.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 % HYPOT overloads robust computation of the square root of the sum of squares for AOs. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: HYPOT overloads robust computation of the square root of the | |
5 % sum of squares for Analysis objects. | |
6 % | |
7 % CALL: ao_out = hypot(ao_in); | |
8 % ao_out = hypot(ao_in, pl); | |
9 % | |
10 % REMARK: The data-object of the output AO is the same as the | |
11 % data-object of the first AO input. The result of HYPOT will | |
12 % be copied to the y values of this data-object if this is | |
13 % called without an output. | |
14 % | |
15 % <a href="matlab:utils.helper.displayMethodInfo('ao', 'hypot')">Parameters Description</a> | |
16 % | |
17 % VERSION: $Id: hypot.m,v 1.13 2011/04/08 08:56:12 hewitson Exp $ | |
18 % | |
19 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
20 | |
21 function varargout = hypot(varargin) | |
22 | |
23 callerIsMethod = utils.helper.callerIsMethod; | |
24 | |
25 operatorName = 'hypot'; | |
26 operatorSymbol = 'hypot'; | |
27 | |
28 % Check if this is a call for parameters | |
29 if utils.helper.isinfocall(varargin{:}) | |
30 varargout{1} = getInfo(varargin{3}); | |
31 return | |
32 end | |
33 | |
34 % Collect input aos, plists and ao variable names | |
35 in_names = cell(size(varargin)); | |
36 for ii = 1:nargin,in_names{ii} = inputname(ii);end | |
37 | |
38 % Collect all AOs | |
39 [as, ao_invars] = utils.helper.collect_objects(varargin(:), 'ao', in_names); | |
40 pl = utils.helper.collect_objects(varargin(:), 'plist', in_names); | |
41 | |
42 % Get default parameters | |
43 pl = parse(pl, getDefaultPlist); | |
44 | |
45 % Check input arguments number | |
46 if numel(as) ~= 2 | |
47 error ('### Incorrect inputs for %s. Please enter 2 AOs', operatorName); | |
48 end | |
49 if nargout == 0 | |
50 error('### %s cannot be used as a modifier. Please give an output variable.', operatorName); | |
51 end | |
52 | |
53 % Go for a deep copy | |
54 bs = copy(as, true); | |
55 | |
56 % Settings | |
57 if callerIsMethod | |
58 infoObj = []; | |
59 pl = plist; | |
60 else | |
61 infoObj = getInfo(); | |
62 pl = getDefaultPlist; | |
63 end | |
64 | |
65 % Apply method | |
66 bs = bs.applyoperator(callerIsMethod, ao_invars, operatorName, operatorSymbol, pl, infoObj); | |
67 % clear errors | |
68 bs.clearErrors; | |
69 | |
70 % Set output | |
71 varargout{1} = bs; | |
72 end | |
73 | |
74 %-------------------------------------------------------------------------- | |
75 % Get Info Object | |
76 %-------------------------------------------------------------------------- | |
77 function ii = getInfo(varargin) | |
78 if nargin == 1 && strcmpi(varargin{1}, 'None') | |
79 sets = {}; | |
80 pl = []; | |
81 else | |
82 sets = {'Default'}; | |
83 pl = getDefaultPlist; | |
84 end | |
85 % Build info object | |
86 ii = minfo(mfilename, 'ao', 'ltpda', utils.const.categories.op, '$Id: hypot.m,v 1.13 2011/04/08 08:56:12 hewitson Exp $', sets, pl); | |
87 ii.setModifier(false); | |
88 ii.setArgsmin(2); | |
89 end | |
90 | |
91 %-------------------------------------------------------------------------- | |
92 % Get Default Plist | |
93 %-------------------------------------------------------------------------- | |
94 function plout = getDefaultPlist() | |
95 persistent pl; | |
96 if ~exist('pl', 'var') || isempty(pl) | |
97 pl = buildplist(); | |
98 end | |
99 plout = pl; | |
100 end | |
101 | |
102 function pl = buildplist() | |
103 pl = plist({'axis', 'The axis on which to compute the sqrt of the sum of the squares.'}, ... | |
104 {2, {'x', 'y', 'xy'}, paramValue.SINGLE}); | |
105 | |
106 end | |
107 |