PageRenderTime 46ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/matlab_tools/Converted/kkmul.m

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