PageRenderTime 44ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/matlab_tools/Converted/kkgplot.m

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