Mercurial > hg > ltpda
comparison m-toolbox/classes/@ao/atan2.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 % ATAN2 overloads the atan2 operator for analysis objects. Four quadrant inverse tangent. | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: ATAN2 overloads the atan2 operator for analysis objects. | |
5 % Four quadrant inverse tangent. | |
6 % | |
7 % REMARK: The data-object of the output AO is the same as the data-object | |
8 % of the first AO input. The result of the atan2 will be copied to | |
9 % the y values of this data-object. | |
10 % | |
11 % CALL: ao_out = atan2(ao1, ao2); | |
12 % ao_out = atan2(ao1, ao2); | |
13 % ao_out = atan2(ao_vec1, ao_vec2); | |
14 % | |
15 % <a href="matlab:utils.helper.displayMethodInfo('ao', 'atan2')">Parameters Description</a> | |
16 % | |
17 % VERSION: $Id: atan2.m,v 1.18 2011/04/08 08:56:12 hewitson Exp $ | |
18 % | |
19 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
20 | |
21 function varargout = atan2(varargin) | |
22 | |
23 callerIsMethod = utils.helper.callerIsMethod; | |
24 | |
25 operatorName = 'atan2'; | |
26 operatorSymbol = 'atan2'; | |
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 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 | |
41 % Check output arguments number | |
42 if nargout == 0 | |
43 error('### %s cannot be used as a modifier. Please give an output variable.', operatorName); | |
44 end | |
45 | |
46 % Check input arguments number | |
47 if length(as) ~= 2 | |
48 error ('### Incorrect inputs for %s. Please enter 2 AOs', operatorName); | |
49 end | |
50 | |
51 % Go for a deep copy | |
52 bs = copy(as, true); | |
53 | |
54 % Settings | |
55 if callerIsMethod | |
56 infoObj = []; | |
57 pl = plist; | |
58 else | |
59 infoObj = getInfo(); | |
60 pl = getDefaultPlist; | |
61 end | |
62 | |
63 % Apply method and set output | |
64 varargout{1} = bs.applyoperator(callerIsMethod, ao_invars, operatorName, operatorSymbol, pl, infoObj); | |
65 | |
66 end | |
67 | |
68 %-------------------------------------------------------------------------- | |
69 % Get Info Object | |
70 %-------------------------------------------------------------------------- | |
71 function ii = getInfo(varargin) | |
72 if nargin == 1 && strcmpi(varargin{1}, 'None') | |
73 sets = {}; | |
74 pl = []; | |
75 else | |
76 sets = {'Default'}; | |
77 pl = getDefaultPlist; | |
78 end | |
79 % Build info object | |
80 ii = minfo(mfilename, 'ao', 'ltpda', utils.const.categories.trig, '$Id: atan2.m,v 1.18 2011/04/08 08:56:12 hewitson Exp $', sets, pl); | |
81 ii.setModifier(false); | |
82 ii.setArgsmin(2); | |
83 end | |
84 | |
85 %-------------------------------------------------------------------------- | |
86 % Get Default Plist | |
87 %-------------------------------------------------------------------------- | |
88 | |
89 function plout = getDefaultPlist() | |
90 persistent pl; | |
91 if ~exist('pl', 'var') || isempty(pl) | |
92 pl = buildplist(); | |
93 end | |
94 plout = pl; | |
95 end | |
96 | |
97 function pl = buildplist() | |
98 pl = plist.EMPTY_PLIST; | |
99 end | |
100 | |
101 |