PageRenderTime 52ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/matlab_tools/Converted/kkatan2.m

http://github.com/aludnam/MATLAB
Objective C | 225 lines | 222 code | 3 blank | 0 comment | 55 complexity | cd6911ef546ebfc468b5290da2497237 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. %kkatan2 'Output = Arc Tangent[Input 1 / (Input 2 or Constant)]'
  2. % This MatLab function was automatically generated by a converter (KhorosToMatLab) from the Khoros katan2.pane file
  3. %
  4. % Parameters:
  5. % InputFile: i1 'Input 1', required: 'First input data object'
  6. % OutputFile: o 'Output', required: 'Resulting output data object'
  7. % InputFile: i2 'Input 2', optional: 'Second input data object'
  8. %
  9. % Example: o = kkatan2({i1, i2}, {'i1','';'o','';'i2',''})
  10. %
  11. % Khoros helpfile follows below:
  12. %
  13. % PROGRAM
  14. % katan2 - Output = Arc Tangent[Input 1 / (Input 2 or Constant)]
  15. %
  16. % DESCRIPTION
  17. % The "Atan2" operator returns the Arc Tangent of the result
  18. % produced by dividing each point in \fBInput 1" by the
  19. % corresponding point in \fBInput 2" or the \fBConstant\fP
  20. % value, which ever is specified by the user.
  21. %
  22. % Executing "Atan2" runs the program \fIkarith2\fP with the -atan2 flag.
  23. %
  24. %
  25. % "Data Type - Single Input" 5
  26. % .cI $DATAMANIP/repos/shared/man/sections/value_type_1input
  27. %
  28. % "Data Type - Two Input Objects" 5
  29. % .cI $DATAMANIP/repos/shared/man/sections/value_type_2input
  30. %
  31. % "Map Data - Single Input" 5
  32. % .cI $DATAMANIP/repos/shared/man/sections/map_1input
  33. %
  34. % "Map Data - Two Input Objects" 5
  35. % .cI $DATAMANIP/repos/shared/man/sections/map_2input
  36. %
  37. % "Validity Mask" 5
  38. % .cI $DATAMANIP/repos/shared/man/sections/mask_2input
  39. %
  40. % "Input Objects of Different Sizes" 5
  41. % .cI $DATAMANIP/repos/shared/man/sections/resize_2input
  42. % The values used to pad the data when input files are not the same size are
  43. % (1.0, 0.0).
  44. %
  45. % "Explicit Location and Time Data - Single Input" 5
  46. % .cI $DATAMANIP/repos/shared/man/sections/loc_and_time_1input
  47. %
  48. % "Explicit Location and Time Data - Two Input Objects" 5
  49. % .cI $DATAMANIP/repos/shared/man/sections/loc_and_time_2input
  50. %
  51. % "Failure Modes - Single Input"
  52. % .cI $DATAMANIP/repos/shared/man/sections/fail_1input
  53. %
  54. % "Failure Modes - Two Input Objects"
  55. % .cI $DATAMANIP/repos/shared/man/sections/fail_2input
  56. %
  57. %
  58. %
  59. % EXAMPLES
  60. %
  61. % "SEE ALSO"
  62. % DATAMANIP::karith2
  63. %
  64. % RESTRICTIONS
  65. % Operations on complex data are not supported at this time. If the
  66. % input object is complex, only the real component of the data is
  67. % processed, and the output object is real. See the "Phase"
  68. % (kphase) or "Complex to Real" (kcmplx2real) operators for complex atan2
  69. % calculation.
  70. %
  71. % REFERENCES
  72. %
  73. % COPYRIGHT
  74. % Copyright (C) 1993 - 1997, Khoral Research, Inc. ("KRI") All rights reserved.
  75. %
  76. function varargout = kkatan2(varargin)
  77. if nargin ==0
  78. Inputs={};arglist={'',''};
  79. elseif nargin ==1
  80. Inputs=varargin{1};arglist={'',''};
  81. elseif nargin ==2
  82. Inputs=varargin{1}; arglist=varargin{2};
  83. else error('Usage: [out1,..] = kkatan2(Inputs,arglist).');
  84. end
  85. if size(arglist,2)~=2
  86. error('arglist must be of form {''ParameterTag1'',value1;''ParameterTag2'',value2}')
  87. end
  88. narglist={'i1', '__input';'o', '__output';'i2', '__input'};
  89. maxval={0,0,1};
  90. minval={0,0,1};
  91. istoggle=[0,0,1];
  92. was_set=istoggle * 0;
  93. paramtype={'InputFile','OutputFile','InputFile'};
  94. % identify the input arrays and assign them to the arguments as stated by the user
  95. if ~iscell(Inputs)
  96. Inputs = {Inputs};
  97. end
  98. NumReqOutputs=1; nextinput=1; nextoutput=1;
  99. for ii=1:size(arglist,1)
  100. wasmatched=0;
  101. for jj=1:size(narglist,1)
  102. if strcmp(arglist{ii,1},narglist{jj,1}) % a given argument was matched to the possible arguments
  103. wasmatched = 1;
  104. was_set(jj) = 1;
  105. if strcmp(narglist{jj,2}, '__input')
  106. if (nextinput > length(Inputs))
  107. error(['Input ' narglist{jj,1} ' has no corresponding input!']);
  108. end
  109. narglist{jj,2} = 'OK_in';
  110. nextinput = nextinput + 1;
  111. elseif strcmp(narglist{jj,2}, '__output')
  112. if (nextoutput > nargout)
  113. error(['Output nr. ' narglist{jj,1} ' is not present in the assignment list of outputs !']);
  114. end
  115. if (isempty(arglist{ii,2}))
  116. narglist{jj,2} = 'OK_out';
  117. else
  118. narglist{jj,2} = arglist{ii,2};
  119. end
  120. nextoutput = nextoutput + 1;
  121. if (minval{jj} == 0)
  122. NumReqOutputs = NumReqOutputs - 1;
  123. end
  124. elseif isstr(arglist{ii,2})
  125. narglist{jj,2} = arglist{ii,2};
  126. else
  127. if strcmp(paramtype{jj}, 'Integer') & (round(arglist{ii,2}) ~= arglist{ii,2})
  128. error(['Argument ' arglist{ii,1} ' is of integer type but non-integer number ' arglist{ii,2} ' was supplied']);
  129. end
  130. if (minval{jj} ~= 0 | maxval{jj} ~= 0)
  131. if (minval{jj} == 1 & maxval{jj} == 1 & arglist{ii,2} < 0)
  132. error(['Argument ' arglist{ii,1} ' must be bigger or equal to zero!']);
  133. elseif (minval{jj} == -1 & maxval{jj} == -1 & arglist{ii,2} > 0)
  134. error(['Argument ' arglist{ii,1} ' must be smaller or equal to zero!']);
  135. elseif (minval{jj} == 2 & maxval{jj} == 2 & arglist{ii,2} <= 0)
  136. error(['Argument ' arglist{ii,1} ' must be bigger than zero!']);
  137. elseif (minval{jj} == -2 & maxval{jj} == -2 & arglist{ii,2} >= 0)
  138. error(['Argument ' arglist{ii,1} ' must be smaller than zero!']);
  139. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} < minval{jj})
  140. error(['Argument ' arglist{ii,1} ' must be bigger than ' num2str(minval{jj})]);
  141. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} > maxval{jj})
  142. error(['Argument ' arglist{ii,1} ' must be smaller than ' num2str(maxval{jj})]);
  143. end
  144. end
  145. end
  146. if ~strcmp(narglist{jj,2},'OK_out') & ~strcmp(narglist{jj,2},'OK_in')
  147. narglist{jj,2} = arglist{ii,2};
  148. end
  149. end
  150. end
  151. if (wasmatched == 0 & ~strcmp(arglist{ii,1},''))
  152. error(['Argument ' arglist{ii,1} ' is not a valid argument for this function']);
  153. end
  154. end
  155. % match the remaining inputs/outputs to the unused arguments and test for missing required inputs
  156. for jj=1:size(narglist,1)
  157. if strcmp(paramtype{jj}, 'Toggle')
  158. if (narglist{jj,2} ==0)
  159. narglist{jj,1} = '';
  160. end;
  161. narglist{jj,2} = '';
  162. end;
  163. if ~strcmp(narglist{jj,2},'__input') && ~strcmp(narglist{jj,2},'__output') && istoggle(jj) && ~ was_set(jj)
  164. narglist{jj,1} = '';
  165. narglist{jj,2} = '';
  166. end;
  167. if strcmp(narglist{jj,2}, '__input')
  168. if (minval{jj} == 0) % meaning this input is required
  169. if (nextinput > size(Inputs))
  170. error(['Required input ' narglist{jj,1} ' has no corresponding input in the list!']);
  171. else
  172. narglist{jj,2} = 'OK_in';
  173. nextinput = nextinput + 1;
  174. end
  175. else % this is an optional input
  176. if (nextinput <= length(Inputs))
  177. narglist{jj,2} = 'OK_in';
  178. nextinput = nextinput + 1;
  179. else
  180. narglist{jj,1} = '';
  181. narglist{jj,2} = '';
  182. end;
  183. end;
  184. else
  185. if strcmp(narglist{jj,2}, '__output')
  186. if (minval{jj} == 0) % this is a required output
  187. if (nextoutput > nargout & nargout > 1)
  188. error(['Required output ' narglist{jj,1} ' is not stated in the assignment list!']);
  189. else
  190. narglist{jj,2} = 'OK_out';
  191. nextoutput = nextoutput + 1;
  192. NumReqOutputs = NumReqOutputs-1;
  193. end
  194. else % this is an optional output
  195. if (nargout - nextoutput >= NumReqOutputs)
  196. narglist{jj,2} = 'OK_out';
  197. nextoutput = nextoutput + 1;
  198. else
  199. narglist{jj,1} = '';
  200. narglist{jj,2} = '';
  201. end;
  202. end
  203. end
  204. end
  205. end
  206. if nargout
  207. varargout = cell(1,nargout);
  208. else
  209. varargout = cell(1,1);
  210. end
  211. global KhorosRoot
  212. if exist('KhorosRoot') && ~isempty(KhorosRoot)
  213. w=['"' KhorosRoot];
  214. else
  215. if ispc
  216. w='"C:\Program Files\dip\khorosBin\';
  217. else
  218. [s,w] = system('which cantata');
  219. w=['"' w(1:end-8)];
  220. end
  221. end
  222. [varargout{:}]=callKhoros([w 'karith2" -atan2'],Inputs,narglist);