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

/matlab_tools/Converted/kcpjoin2bands.m

http://github.com/aludnam/MATLAB
Objective C | 183 lines | 180 code | 3 blank | 0 comment | 55 complexity | 32a5365fd10f76ee9fceaa08a3dfaf39 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. %kcpjoin2bands 'join 2 bands to create a 2-element object '
  2. % This MatLab function was automatically generated by a converter (KhorosToMatLab) from the Khoros cpjoin2bands.pane file
  3. %
  4. % Parameters:
  5. % InputFile: i1 'Input Band 1', required: 'First Input data object'
  6. % InputFile: i2 'Input Band 2', required: 'input file'
  7. % OutputFile: o 'Output', required: 'Resulting output data object'
  8. %
  9. % Example: o = kcpjoin2bands({i1, i2}, {'i1','';'i2','';'o',''})
  10. %
  11. % Khoros helpfile follows below:
  12. %
  13. % PROGRAM
  14. % cpjoin2bands - join 2 bands to create a 2-element object
  15. %
  16. % DESCRIPTION
  17. % A pane object that calls kappend to create a 2-element object from two separate bands.
  18. %
  19. %
  20. %
  21. % EXAMPLES
  22. %
  23. % "SEE ALSO"
  24. % cpjoin3bands, cpjoin4bands
  25. %
  26. % RESTRICTIONS
  27. %
  28. % REFERENCES
  29. % All references for the toolbox COLOR are on the file $COLOR/Readme.html file.
  30. %
  31. % COPYRIGHT
  32. % Copyright (C) 1997 Rafael Santos. Khoros (C) Khoral Research, Inc.
  33. %
  34. function varargout = kcpjoin2bands(varargin)
  35. if nargin ==0
  36. Inputs={};arglist={'',''};
  37. elseif nargin ==1
  38. Inputs=varargin{1};arglist={'',''};
  39. elseif nargin ==2
  40. Inputs=varargin{1}; arglist=varargin{2};
  41. else error('Usage: [out1,..] = kcpjoin2bands(Inputs,arglist).');
  42. end
  43. if size(arglist,2)~=2
  44. error('arglist must be of form {''ParameterTag1'',value1;''ParameterTag2'',value2}')
  45. end
  46. narglist={'i1', '__input';'i2', '__input';'o', '__output'};
  47. maxval={0,0,0};
  48. minval={0,0,0};
  49. istoggle=[0,0,0];
  50. was_set=istoggle * 0;
  51. paramtype={'InputFile','InputFile','OutputFile'};
  52. % identify the input arrays and assign them to the arguments as stated by the user
  53. if ~iscell(Inputs)
  54. Inputs = {Inputs};
  55. end
  56. NumReqOutputs=1; nextinput=1; nextoutput=1;
  57. for ii=1:size(arglist,1)
  58. wasmatched=0;
  59. for jj=1:size(narglist,1)
  60. if strcmp(arglist{ii,1},narglist{jj,1}) % a given argument was matched to the possible arguments
  61. wasmatched = 1;
  62. was_set(jj) = 1;
  63. if strcmp(narglist{jj,2}, '__input')
  64. if (nextinput > length(Inputs))
  65. error(['Input ' narglist{jj,1} ' has no corresponding input!']);
  66. end
  67. narglist{jj,2} = 'OK_in';
  68. nextinput = nextinput + 1;
  69. elseif strcmp(narglist{jj,2}, '__output')
  70. if (nextoutput > nargout)
  71. error(['Output nr. ' narglist{jj,1} ' is not present in the assignment list of outputs !']);
  72. end
  73. if (isempty(arglist{ii,2}))
  74. narglist{jj,2} = 'OK_out';
  75. else
  76. narglist{jj,2} = arglist{ii,2};
  77. end
  78. nextoutput = nextoutput + 1;
  79. if (minval{jj} == 0)
  80. NumReqOutputs = NumReqOutputs - 1;
  81. end
  82. elseif isstr(arglist{ii,2})
  83. narglist{jj,2} = arglist{ii,2};
  84. else
  85. if strcmp(paramtype{jj}, 'Integer') & (round(arglist{ii,2}) ~= arglist{ii,2})
  86. error(['Argument ' arglist{ii,1} ' is of integer type but non-integer number ' arglist{ii,2} ' was supplied']);
  87. end
  88. if (minval{jj} ~= 0 | maxval{jj} ~= 0)
  89. if (minval{jj} == 1 & maxval{jj} == 1 & arglist{ii,2} < 0)
  90. error(['Argument ' arglist{ii,1} ' must be bigger or equal to zero!']);
  91. elseif (minval{jj} == -1 & maxval{jj} == -1 & arglist{ii,2} > 0)
  92. error(['Argument ' arglist{ii,1} ' must be smaller or equal to zero!']);
  93. elseif (minval{jj} == 2 & maxval{jj} == 2 & arglist{ii,2} <= 0)
  94. error(['Argument ' arglist{ii,1} ' must be bigger than zero!']);
  95. elseif (minval{jj} == -2 & maxval{jj} == -2 & arglist{ii,2} >= 0)
  96. error(['Argument ' arglist{ii,1} ' must be smaller than zero!']);
  97. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} < minval{jj})
  98. error(['Argument ' arglist{ii,1} ' must be bigger than ' num2str(minval{jj})]);
  99. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} > maxval{jj})
  100. error(['Argument ' arglist{ii,1} ' must be smaller than ' num2str(maxval{jj})]);
  101. end
  102. end
  103. end
  104. if ~strcmp(narglist{jj,2},'OK_out') & ~strcmp(narglist{jj,2},'OK_in')
  105. narglist{jj,2} = arglist{ii,2};
  106. end
  107. end
  108. end
  109. if (wasmatched == 0 & ~strcmp(arglist{ii,1},''))
  110. error(['Argument ' arglist{ii,1} ' is not a valid argument for this function']);
  111. end
  112. end
  113. % match the remaining inputs/outputs to the unused arguments and test for missing required inputs
  114. for jj=1:size(narglist,1)
  115. if strcmp(paramtype{jj}, 'Toggle')
  116. if (narglist{jj,2} ==0)
  117. narglist{jj,1} = '';
  118. end;
  119. narglist{jj,2} = '';
  120. end;
  121. if ~strcmp(narglist{jj,2},'__input') && ~strcmp(narglist{jj,2},'__output') && istoggle(jj) && ~ was_set(jj)
  122. narglist{jj,1} = '';
  123. narglist{jj,2} = '';
  124. end;
  125. if strcmp(narglist{jj,2}, '__input')
  126. if (minval{jj} == 0) % meaning this input is required
  127. if (nextinput > size(Inputs))
  128. error(['Required input ' narglist{jj,1} ' has no corresponding input in the list!']);
  129. else
  130. narglist{jj,2} = 'OK_in';
  131. nextinput = nextinput + 1;
  132. end
  133. else % this is an optional input
  134. if (nextinput <= length(Inputs))
  135. narglist{jj,2} = 'OK_in';
  136. nextinput = nextinput + 1;
  137. else
  138. narglist{jj,1} = '';
  139. narglist{jj,2} = '';
  140. end;
  141. end;
  142. else
  143. if strcmp(narglist{jj,2}, '__output')
  144. if (minval{jj} == 0) % this is a required output
  145. if (nextoutput > nargout & nargout > 1)
  146. error(['Required output ' narglist{jj,1} ' is not stated in the assignment list!']);
  147. else
  148. narglist{jj,2} = 'OK_out';
  149. nextoutput = nextoutput + 1;
  150. NumReqOutputs = NumReqOutputs-1;
  151. end
  152. else % this is an optional output
  153. if (nargout - nextoutput >= NumReqOutputs)
  154. narglist{jj,2} = 'OK_out';
  155. nextoutput = nextoutput + 1;
  156. else
  157. narglist{jj,1} = '';
  158. narglist{jj,2} = '';
  159. end;
  160. end
  161. end
  162. end
  163. end
  164. if nargout
  165. varargout = cell(1,nargout);
  166. else
  167. varargout = cell(1,1);
  168. end
  169. global KhorosRoot
  170. if exist('KhorosRoot') && ~isempty(KhorosRoot)
  171. w=['"' KhorosRoot];
  172. else
  173. if ispc
  174. w='"C:\Program Files\dip\khorosBin\';
  175. else
  176. [s,w] = system('which cantata');
  177. w=['"' w(1:end-8)];
  178. end
  179. end
  180. [varargout{:}]=callKhoros([w 'kappend" -e'],Inputs,narglist);