PageRenderTime 51ms CodeModel.GetById 13ms RepoModel.GetById 1ms app.codeStats 0ms

/matlab_tools/Converted/kkne.m

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