PageRenderTime 40ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/matlab_tools/Converted/kgplot.m

http://github.com/aludnam/MATLAB
Objective C | 214 lines | 211 code | 3 blank | 0 comment | 67 complexity | 11f9ae5cdbf547e148b684c66bbb43e9 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. %kgplot 'Visualizes 2D Data '
  2. % This MatLab function was automatically generated by a converter (KhorosToMatLab) from the Khoros gplot.pane file
  3. %
  4. % Parameters:
  5. % InputFile: i 'Input ', required: 'Input file to be plotted. The values are ordered along X direction. If a second row is present, it is interpreted as error information. More than 2 rows are interpreted such as to plot a 2D map.'
  6. % InputFile: ci 'Coordinates', optional: 'File with x-coordinates for datapoints'
  7. % Toggle: v 'input is vectorfile', default: 0: 'if pressed input is interpreted as having vector coordinates in column 1,2,3'
  8. % InputFile: vl 'Vector directions', optional: 'File with vectors for length and directions'
  9. % String: p 'Preamble', default: '# separate with ;': 'init for gnuplot'
  10. % Double: sc 'XScale', default: 1: 'scaling for x-axis'
  11. % Double: of 'XOffset', default: 0: 'offset for x-axis'
  12. % String: ftitle 'Fit Title', default: 'Fitted Function': 'title of fit-curve'
  13. % String: fitf 'Fit-Funktion', default: 'f(x)': 'funktionname to fit. This can also be f(x,y) for a 2d-function'
  14. % String: fit '= ', default: 'I0*exp(-log(2)*(2*(x-POS)/FWHM)**2)': 'funktion to fit to data'
  15. % Integer: fn 'Fit to Element', default: 0: 'element nr of the data, to fit to'
  16. % String: fits 'start', default: 'I0=1.0; POS=0.1; FWHM=10.0': 'values to start with'
  17. % String: via 'via', default: 'I0,POS,FWHM': 'variable parameters'
  18. % Toggle: fiterrors 'Use Errorbars in Fit', default: 0: 'If selected, error information, if present in the data will be used also for the fit.'
  19. % String: xfitrange 'XFitRange', default: '[0.0 : 1.0]': 'x-range for fitting data'
  20. % String: title 'Title', default: 'My Title': 'string'
  21. % String: xtitle 'XTitle', default: 'Distance [nm]': 'Title of X-Axis'
  22. % String: xrange 'XRange', default: '[0.0 : 1.0]': 'Range for plotting in x'
  23. % String: ytitle 'YTitle', default: 'Intensity [a.u.]': 'title of y axis'
  24. % String: yrange 'YRange', default: '[0.0 : 255.0]': 'Range for plotting in y'
  25. % String: ztitle 'ZTitle', default: 'Intensity [a.u.]': 'title of z axis'
  26. % String: zrange 'ZRange', default: '[0.0 : 255.0]': 'Range for plotting in z'
  27. % String: dtitle0 'DataTitle Elem 0', default: 'Dataset 1': 'title of data to be plotted'
  28. % String: dext0 'Extention Elem 0', default: 'with boxes': 'plotting extention'
  29. % String: dtitle1 'DataTitle Elem 1', default: 'Dataset 2': 'title of data to be plotted'
  30. % String: dext1 'Extention Elem 1', default: 'with boxes': 'plotting extention'
  31. % String: dtitle2 'DataTitle Elem 2', default: 'Dataset 3': 'title of data to be plotted'
  32. % String: dext2 'Extention Elem 2', default: 'with boxes': 'plotting extention'
  33. % String: dtitle3 'DataTitle Elem 3', default: 'Dataset 4': 'title of data to be plotted'
  34. % String: dext3 'Extention Elem 3', default: 'with boxes': 'plotting extention'
  35. % Toggle: gp 'start gnuplot', default: 0: 'executes gnuplot immediately'
  36. % Toggle: land 'use landscape output', default: 0: 'generates landscape postscript'
  37. % Toggle: c 'use color', default: 0: 'generates color postscript'
  38. % Integer: fontsize 'PS Font Size', default: 24: 'size of the font used for ps output'
  39. % Toggle: eps 'generate EPS', default: 0: 'generates eps instead of ps'
  40. % OutputFile: o 'Output', required: 'Resulting output data object'
  41. % OutputFile: ps Output', optional: 'name of postscript file to generate'
  42. %
  43. % Example: [o, ps] = kgplot({i, ci, vl}, {'i','';'ci','';'v',0;'vl','';'p','# separate with ;';'sc',1;'of',0;'ftitle','Fitted Function';'fitf','f(x)';'fit','I0*exp(-log(2)*(2*(x-POS)/FWHM)**2)';'fn',0;'fits','I0=1.0; POS=0.1; FWHM=10.0';'via','I0,POS,FWHM';'fiterrors',0;'xfitrange','[0.0 : 1.0]';'title','My Title';'xtitle','Distance [nm]';'xrange','[0.0 : 1.0]';'ytitle','Intensity [a.u.]';'yrange','[0.0 : 255.0]';'ztitle','Intensity [a.u.]';'zrange','[0.0 : 255.0]';'dtitle0','Dataset 1';'dext0','with boxes';'dtitle1','Dataset 2';'dext1','with boxes';'dtitle2','Dataset 3';'dext2','with boxes';'dtitle3','Dataset 4';'dext3','with boxes';'gp',0;'land',0;'c',0;'fontsize',24;'eps',0;'o','';'ps',''})
  44. %
  45. % Khoros helpfile follows below:
  46. %
  47. % PROGRAM
  48. % gplot - Visualizes 2D Data
  49. %
  50. % DESCRIPTION
  51. %
  52. %
  53. %
  54. % EXAMPLES
  55. %
  56. % "SEE ALSO"
  57. %
  58. % RESTRICTIONS
  59. %
  60. % REFERENCES
  61. %
  62. % COPYRIGHT
  63. % Copyright (C) 1996-2003, Rainer Heintzmann, All rights reserved.
  64. %
  65. function varargout = kgplot(varargin)
  66. if nargin ==0
  67. Inputs={};arglist={'',''};
  68. elseif nargin ==1
  69. Inputs=varargin{1};arglist={'',''};
  70. elseif nargin ==2
  71. Inputs=varargin{1}; arglist=varargin{2};
  72. else error('Usage: [out1,..] = kgplot(Inputs,arglist).');
  73. end
  74. if size(arglist,2)~=2
  75. error('arglist must be of form {''ParameterTag1'',value1;''ParameterTag2'',value2}')
  76. end
  77. narglist={'i', '__input';'ci', '__input';'v', 0;'vl', '__input';'p', '# separate with ;';'sc', 1;'of', 0;'ftitle', 'Fitted Function';'fitf', 'f(x)';'fit', 'I0*exp(-log(2)*(2*(x-POS)/FWHM)**2)';'fn', 0;'fits', 'I0=1.0; POS=0.1; FWHM=10.0';'via', 'I0,POS,FWHM';'fiterrors', 0;'xfitrange', '[0.0 : 1.0]';'title', 'My Title';'xtitle', 'Distance [nm]';'xrange', '[0.0 : 1.0]';'ytitle', 'Intensity [a.u.]';'yrange', '[0.0 : 255.0]';'ztitle', 'Intensity [a.u.]';'zrange', '[0.0 : 255.0]';'dtitle0', 'Dataset 1';'dext0', 'with boxes';'dtitle1', 'Dataset 2';'dext1', 'with boxes';'dtitle2', 'Dataset 3';'dext2', 'with boxes';'dtitle3', 'Dataset 4';'dext3', 'with boxes';'gp', 0;'land', 0;'c', 0;'fontsize', 24;'eps', 0;'o', '__output';'ps', '__output'};
  78. maxval={0,1,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,1};
  79. minval={0,1,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,1};
  80. istoggle=[0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1];
  81. was_set=istoggle * 0;
  82. paramtype={'InputFile','InputFile','Toggle','InputFile','String','Double','Double','String','String','String','Integer','String','String','Toggle','String','String','String','String','String','String','String','String','String','String','String','String','String','String','String','String','Toggle','Toggle','Toggle','Integer','Toggle','OutputFile','OutputFile'};
  83. % identify the input arrays and assign them to the arguments as stated by the user
  84. if ~iscell(Inputs)
  85. Inputs = {Inputs};
  86. end
  87. NumReqOutputs=1; nextinput=1; nextoutput=1;
  88. for ii=1:size(arglist,1)
  89. wasmatched=0;
  90. for jj=1:size(narglist,1)
  91. if strcmp(arglist{ii,1},narglist{jj,1}) % a given argument was matched to the possible arguments
  92. wasmatched = 1;
  93. was_set(jj) = 1;
  94. if strcmp(narglist{jj,2}, '__input')
  95. if (nextinput > length(Inputs))
  96. error(['Input ' narglist{jj,1} ' has no corresponding input!']);
  97. end
  98. narglist{jj,2} = 'OK_in';
  99. nextinput = nextinput + 1;
  100. elseif strcmp(narglist{jj,2}, '__output')
  101. if (nextoutput > nargout)
  102. error(['Output nr. ' narglist{jj,1} ' is not present in the assignment list of outputs !']);
  103. end
  104. if (isempty(arglist{ii,2}))
  105. narglist{jj,2} = 'OK_out';
  106. else
  107. narglist{jj,2} = arglist{ii,2};
  108. end
  109. nextoutput = nextoutput + 1;
  110. if (minval{jj} == 0)
  111. NumReqOutputs = NumReqOutputs - 1;
  112. end
  113. elseif isstr(arglist{ii,2})
  114. narglist{jj,2} = arglist{ii,2};
  115. else
  116. if strcmp(paramtype{jj}, 'Integer') & (round(arglist{ii,2}) ~= arglist{ii,2})
  117. error(['Argument ' arglist{ii,1} ' is of integer type but non-integer number ' arglist{ii,2} ' was supplied']);
  118. end
  119. if (minval{jj} ~= 0 | maxval{jj} ~= 0)
  120. if (minval{jj} == 1 & maxval{jj} == 1 & arglist{ii,2} < 0)
  121. error(['Argument ' arglist{ii,1} ' must be bigger or equal to zero!']);
  122. elseif (minval{jj} == -1 & maxval{jj} == -1 & arglist{ii,2} > 0)
  123. error(['Argument ' arglist{ii,1} ' must be smaller or equal to zero!']);
  124. elseif (minval{jj} == 2 & maxval{jj} == 2 & arglist{ii,2} <= 0)
  125. error(['Argument ' arglist{ii,1} ' must be bigger than zero!']);
  126. elseif (minval{jj} == -2 & maxval{jj} == -2 & arglist{ii,2} >= 0)
  127. error(['Argument ' arglist{ii,1} ' must be smaller than zero!']);
  128. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} < minval{jj})
  129. error(['Argument ' arglist{ii,1} ' must be bigger than ' num2str(minval{jj})]);
  130. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} > maxval{jj})
  131. error(['Argument ' arglist{ii,1} ' must be smaller than ' num2str(maxval{jj})]);
  132. end
  133. end
  134. end
  135. if ~strcmp(narglist{jj,2},'OK_out') & ~strcmp(narglist{jj,2},'OK_in')
  136. narglist{jj,2} = arglist{ii,2};
  137. end
  138. end
  139. end
  140. if (wasmatched == 0 & ~strcmp(arglist{ii,1},''))
  141. error(['Argument ' arglist{ii,1} ' is not a valid argument for this function']);
  142. end
  143. end
  144. % match the remaining inputs/outputs to the unused arguments and test for missing required inputs
  145. for jj=1:size(narglist,1)
  146. if strcmp(paramtype{jj}, 'Toggle')
  147. if (narglist{jj,2} ==0)
  148. narglist{jj,1} = '';
  149. end;
  150. narglist{jj,2} = '';
  151. end;
  152. if ~strcmp(narglist{jj,2},'__input') && ~strcmp(narglist{jj,2},'__output') && istoggle(jj) && ~ was_set(jj)
  153. narglist{jj,1} = '';
  154. narglist{jj,2} = '';
  155. end;
  156. if strcmp(narglist{jj,2}, '__input')
  157. if (minval{jj} == 0) % meaning this input is required
  158. if (nextinput > size(Inputs))
  159. error(['Required input ' narglist{jj,1} ' has no corresponding input in the list!']);
  160. else
  161. narglist{jj,2} = 'OK_in';
  162. nextinput = nextinput + 1;
  163. end
  164. else % this is an optional input
  165. if (nextinput <= length(Inputs))
  166. narglist{jj,2} = 'OK_in';
  167. nextinput = nextinput + 1;
  168. else
  169. narglist{jj,1} = '';
  170. narglist{jj,2} = '';
  171. end;
  172. end;
  173. else
  174. if strcmp(narglist{jj,2}, '__output')
  175. if (minval{jj} == 0) % this is a required output
  176. if (nextoutput > nargout & nargout > 1)
  177. error(['Required output ' narglist{jj,1} ' is not stated in the assignment list!']);
  178. else
  179. narglist{jj,2} = 'OK_out';
  180. nextoutput = nextoutput + 1;
  181. NumReqOutputs = NumReqOutputs-1;
  182. end
  183. else % this is an optional output
  184. if (nargout - nextoutput >= NumReqOutputs)
  185. narglist{jj,2} = 'OK_out';
  186. nextoutput = nextoutput + 1;
  187. else
  188. narglist{jj,1} = '';
  189. narglist{jj,2} = '';
  190. end;
  191. end
  192. end
  193. end
  194. end
  195. if nargout
  196. varargout = cell(1,nargout);
  197. else
  198. varargout = cell(1,1);
  199. end
  200. global KhorosRoot
  201. if exist('KhorosRoot') && ~isempty(KhorosRoot)
  202. w=['"' KhorosRoot];
  203. else
  204. if ispc
  205. w='"C:\Program Files\dip\khorosBin\';
  206. else
  207. [s,w] = system('which cantata');
  208. w=['"' w(1:end-8)];
  209. end
  210. end
  211. [varargout{:}]=callKhoros([w 'gplot" -k'],Inputs,narglist);