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

/matlab_tools/Converted/kklt.m

http://github.com/aludnam/MATLAB
Objective C | 236 lines | 233 code | 3 blank | 0 comment | 58 complexity | 57b496bd6489dbe62e91fbf3c787b589 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. %kklt 'IF Input 1 is Less Than (Input 2 or Constant), Output = TRUE'
  2. % This MatLab function was automatically generated by a converter (KhorosToMatLab) from the Khoros klt.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 = kklt({i1, i2}, {'i1','';'o','';'i2',''})
  10. %
  11. % Khoros helpfile follows below:
  12. %
  13. % PROGRAM
  14. % klt - IF Input 1 is Less Than (Input 2 or Constant), Output = TRUE
  15. %
  16. % DESCRIPTION
  17. % The LESS THAN comparison operator compares each point in \fBInput 1"
  18. % either with the corresponding point in \fBInput 2" or with the
  19. % \fBConstant" value, which ever is specified by the user.
  20. % If the value from \fBInput 1" is less than the
  21. % value from \fBInput 2" or the \fBConstant\fP, the corresponding point
  22. % in \fBOutput" will be
  23. % assigned the value specified by \fBTRUE Value". If the value from
  24. % \fBInput 1" is not less than the value against which
  25. % it is being compared, the corresponding point in \fBOutput" will be
  26. % the value specified by \fBFALSE Value".
  27. %
  28. % "Data Type - Single Input" 5
  29. % .cI $DATAMANIP/repos/shared/man/sections/value_type_1input
  30. %
  31. % "Data Type - Two Input Objects" 5
  32. % .cI $DATAMANIP/repos/shared/man/sections/value_type_2input
  33. %
  34. % "Map Data" 5
  35. % The comparison operations have not been written to be fully polymorphic yet.
  36. % They does not
  37. % check for map data, and will therefore always operate on the value data,
  38. % even if a map exists. This will most likely corrupt indexing into the map.
  39. % In the case of a single input, it is recommended to use the "Copy to
  40. % Value" (kcptoval) segment operator to temporarily move the map data into
  41. % the value segment, run the operator on the data, then move it back to the
  42. % map with the "Copy from Value" (kcpfromval) operator.
  43. % When operating with two input objects, where at least one of the objects
  44. % contains map data, data should be mapped prior to running the comparison
  45. % operator. The "Map Data" operator (kmapdata) can be used to perform
  46. % the mapping operation.
  47. %
  48. % "Validity Mask - Single Input" 5
  49. % .cI $DATAMANIP/repos/shared/man/sections/mask_1input
  50. %
  51. % "Validity Mask - Two Input Objects" 5
  52. % Masking has not been implemented yet for the comparison operators. Therefore,
  53. % only the mask from the first input object will be transferred to the output.
  54. %
  55. % "Input Objects of Different Sizes" 5
  56. % .cI $DATAMANIP/repos/shared/man/sections/resize_2input
  57. % The value used to pad the data when the input files are not the same size is
  58. % zero.
  59. %
  60. % "Explicit Location and Time Data - Single Input" 5
  61. % .cI $DATAMANIP/repos/shared/man/sections/loc_and_time_1input
  62. %
  63. % "Explicit Location and Time Data - Two Input Objects" 5
  64. % The comparison operations have not been extended to understand location and
  65. % time data. Therefore, only location and time data present in the first input
  66. % object will be transferred to the output.
  67. %
  68. % Executing the Less Than operator runs the program "kcompare" with the -lt flag.
  69. %
  70. %
  71. %
  72. % EXAMPLES
  73. %
  74. % "SEE ALSO"
  75. % DATAMANIP::kcompare
  76. %
  77. % RESTRICTIONS
  78. % This routine is still under development, and has not been modified to fully
  79. % support the polymorphic data model. See paragraphs above for discussions
  80. % concerning the polymorphic data segments.
  81. %
  82. % REFERENCES
  83. %
  84. % COPYRIGHT
  85. % Copyright (C) 1993 - 1997, Khoral Research, Inc. ("KRI") All rights reserved.
  86. %
  87. function varargout = kklt(varargin)
  88. if nargin ==0
  89. Inputs={};arglist={'',''};
  90. elseif nargin ==1
  91. Inputs=varargin{1};arglist={'',''};
  92. elseif nargin ==2
  93. Inputs=varargin{1}; arglist=varargin{2};
  94. else error('Usage: [out1,..] = kklt(Inputs,arglist).');
  95. end
  96. if size(arglist,2)~=2
  97. error('arglist must be of form {''ParameterTag1'',value1;''ParameterTag2'',value2}')
  98. end
  99. narglist={'i1', '__input';'o', '__output';'i2', '__input'};
  100. maxval={0,0,1};
  101. minval={0,0,1};
  102. istoggle=[0,0,1];
  103. was_set=istoggle * 0;
  104. paramtype={'InputFile','OutputFile','InputFile'};
  105. % identify the input arrays and assign them to the arguments as stated by the user
  106. if ~iscell(Inputs)
  107. Inputs = {Inputs};
  108. end
  109. NumReqOutputs=1; nextinput=1; nextoutput=1;
  110. for ii=1:size(arglist,1)
  111. wasmatched=0;
  112. for jj=1:size(narglist,1)
  113. if strcmp(arglist{ii,1},narglist{jj,1}) % a given argument was matched to the possible arguments
  114. wasmatched = 1;
  115. was_set(jj) = 1;
  116. if strcmp(narglist{jj,2}, '__input')
  117. if (nextinput > length(Inputs))
  118. error(['Input ' narglist{jj,1} ' has no corresponding input!']);
  119. end
  120. narglist{jj,2} = 'OK_in';
  121. nextinput = nextinput + 1;
  122. elseif strcmp(narglist{jj,2}, '__output')
  123. if (nextoutput > nargout)
  124. error(['Output nr. ' narglist{jj,1} ' is not present in the assignment list of outputs !']);
  125. end
  126. if (isempty(arglist{ii,2}))
  127. narglist{jj,2} = 'OK_out';
  128. else
  129. narglist{jj,2} = arglist{ii,2};
  130. end
  131. nextoutput = nextoutput + 1;
  132. if (minval{jj} == 0)
  133. NumReqOutputs = NumReqOutputs - 1;
  134. end
  135. elseif isstr(arglist{ii,2})
  136. narglist{jj,2} = arglist{ii,2};
  137. else
  138. if strcmp(paramtype{jj}, 'Integer') & (round(arglist{ii,2}) ~= arglist{ii,2})
  139. error(['Argument ' arglist{ii,1} ' is of integer type but non-integer number ' arglist{ii,2} ' was supplied']);
  140. end
  141. if (minval{jj} ~= 0 | maxval{jj} ~= 0)
  142. if (minval{jj} == 1 & maxval{jj} == 1 & arglist{ii,2} < 0)
  143. error(['Argument ' arglist{ii,1} ' must be bigger or equal to zero!']);
  144. elseif (minval{jj} == -1 & maxval{jj} == -1 & arglist{ii,2} > 0)
  145. error(['Argument ' arglist{ii,1} ' must be smaller or equal to zero!']);
  146. elseif (minval{jj} == 2 & maxval{jj} == 2 & arglist{ii,2} <= 0)
  147. error(['Argument ' arglist{ii,1} ' must be bigger than zero!']);
  148. elseif (minval{jj} == -2 & maxval{jj} == -2 & arglist{ii,2} >= 0)
  149. error(['Argument ' arglist{ii,1} ' must be smaller than zero!']);
  150. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} < minval{jj})
  151. error(['Argument ' arglist{ii,1} ' must be bigger than ' num2str(minval{jj})]);
  152. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} > maxval{jj})
  153. error(['Argument ' arglist{ii,1} ' must be smaller than ' num2str(maxval{jj})]);
  154. end
  155. end
  156. end
  157. if ~strcmp(narglist{jj,2},'OK_out') & ~strcmp(narglist{jj,2},'OK_in')
  158. narglist{jj,2} = arglist{ii,2};
  159. end
  160. end
  161. end
  162. if (wasmatched == 0 & ~strcmp(arglist{ii,1},''))
  163. error(['Argument ' arglist{ii,1} ' is not a valid argument for this function']);
  164. end
  165. end
  166. % match the remaining inputs/outputs to the unused arguments and test for missing required inputs
  167. for jj=1:size(narglist,1)
  168. if strcmp(paramtype{jj}, 'Toggle')
  169. if (narglist{jj,2} ==0)
  170. narglist{jj,1} = '';
  171. end;
  172. narglist{jj,2} = '';
  173. end;
  174. if ~strcmp(narglist{jj,2},'__input') && ~strcmp(narglist{jj,2},'__output') && istoggle(jj) && ~ was_set(jj)
  175. narglist{jj,1} = '';
  176. narglist{jj,2} = '';
  177. end;
  178. if strcmp(narglist{jj,2}, '__input')
  179. if (minval{jj} == 0) % meaning this input is required
  180. if (nextinput > size(Inputs))
  181. error(['Required input ' narglist{jj,1} ' has no corresponding input in the list!']);
  182. else
  183. narglist{jj,2} = 'OK_in';
  184. nextinput = nextinput + 1;
  185. end
  186. else % this is an optional input
  187. if (nextinput <= length(Inputs))
  188. narglist{jj,2} = 'OK_in';
  189. nextinput = nextinput + 1;
  190. else
  191. narglist{jj,1} = '';
  192. narglist{jj,2} = '';
  193. end;
  194. end;
  195. else
  196. if strcmp(narglist{jj,2}, '__output')
  197. if (minval{jj} == 0) % this is a required output
  198. if (nextoutput > nargout & nargout > 1)
  199. error(['Required output ' narglist{jj,1} ' is not stated in the assignment list!']);
  200. else
  201. narglist{jj,2} = 'OK_out';
  202. nextoutput = nextoutput + 1;
  203. NumReqOutputs = NumReqOutputs-1;
  204. end
  205. else % this is an optional output
  206. if (nargout - nextoutput >= NumReqOutputs)
  207. narglist{jj,2} = 'OK_out';
  208. nextoutput = nextoutput + 1;
  209. else
  210. narglist{jj,1} = '';
  211. narglist{jj,2} = '';
  212. end;
  213. end
  214. end
  215. end
  216. end
  217. if nargout
  218. varargout = cell(1,nargout);
  219. else
  220. varargout = cell(1,1);
  221. end
  222. global KhorosRoot
  223. if exist('KhorosRoot') && ~isempty(KhorosRoot)
  224. w=['"' KhorosRoot];
  225. else
  226. if ispc
  227. w='"C:\Program Files\dip\khorosBin\';
  228. else
  229. [s,w] = system('which cantata');
  230. w=['"' w(1:end-8)];
  231. end
  232. end
  233. [varargout{:}]=callKhoros([w 'kcompare" -lt'],Inputs,narglist);