/matlab_tools/Converted/kgplot.m
Objective C | 214 lines | 211 code | 3 blank | 0 comment | 67 complexity | 11f9ae5cdbf547e148b684c66bbb43e9 MD5 | raw file
Possible License(s): BSD-3-Clause
- %kgplot 'Visualizes 2D Data '
- % This MatLab function was automatically generated by a converter (KhorosToMatLab) from the Khoros gplot.pane file
- %
- % Parameters:
- % 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.'
- % InputFile: ci 'Coordinates', optional: 'File with x-coordinates for datapoints'
- % Toggle: v 'input is vectorfile', default: 0: 'if pressed input is interpreted as having vector coordinates in column 1,2,3'
- % InputFile: vl 'Vector directions', optional: 'File with vectors for length and directions'
- % String: p 'Preamble', default: '# separate with ;': 'init for gnuplot'
- % Double: sc 'XScale', default: 1: 'scaling for x-axis'
- % Double: of 'XOffset', default: 0: 'offset for x-axis'
- % String: ftitle 'Fit Title', default: 'Fitted Function': 'title of fit-curve'
- % String: fitf 'Fit-Funktion', default: 'f(x)': 'funktionname to fit. This can also be f(x,y) for a 2d-function'
- % String: fit '= ', default: 'I0*exp(-log(2)*(2*(x-POS)/FWHM)**2)': 'funktion to fit to data'
- % Integer: fn 'Fit to Element', default: 0: 'element nr of the data, to fit to'
- % String: fits 'start', default: 'I0=1.0; POS=0.1; FWHM=10.0': 'values to start with'
- % String: via 'via', default: 'I0,POS,FWHM': 'variable parameters'
- % Toggle: fiterrors 'Use Errorbars in Fit', default: 0: 'If selected, error information, if present in the data will be used also for the fit.'
- % String: xfitrange 'XFitRange', default: '[0.0 : 1.0]': 'x-range for fitting data'
- % String: title 'Title', default: 'My Title': 'string'
- % String: xtitle 'XTitle', default: 'Distance [nm]': 'Title of X-Axis'
- % String: xrange 'XRange', default: '[0.0 : 1.0]': 'Range for plotting in x'
- % String: ytitle 'YTitle', default: 'Intensity [a.u.]': 'title of y axis'
- % String: yrange 'YRange', default: '[0.0 : 255.0]': 'Range for plotting in y'
- % String: ztitle 'ZTitle', default: 'Intensity [a.u.]': 'title of z axis'
- % String: zrange 'ZRange', default: '[0.0 : 255.0]': 'Range for plotting in z'
- % String: dtitle0 'DataTitle Elem 0', default: 'Dataset 1': 'title of data to be plotted'
- % String: dext0 'Extention Elem 0', default: 'with boxes': 'plotting extention'
- % String: dtitle1 'DataTitle Elem 1', default: 'Dataset 2': 'title of data to be plotted'
- % String: dext1 'Extention Elem 1', default: 'with boxes': 'plotting extention'
- % String: dtitle2 'DataTitle Elem 2', default: 'Dataset 3': 'title of data to be plotted'
- % String: dext2 'Extention Elem 2', default: 'with boxes': 'plotting extention'
- % String: dtitle3 'DataTitle Elem 3', default: 'Dataset 4': 'title of data to be plotted'
- % String: dext3 'Extention Elem 3', default: 'with boxes': 'plotting extention'
- % Toggle: gp 'start gnuplot', default: 0: 'executes gnuplot immediately'
- % Toggle: land 'use landscape output', default: 0: 'generates landscape postscript'
- % Toggle: c 'use color', default: 0: 'generates color postscript'
- % Integer: fontsize 'PS Font Size', default: 24: 'size of the font used for ps output'
- % Toggle: eps 'generate EPS', default: 0: 'generates eps instead of ps'
- % OutputFile: o 'Output', required: 'Resulting output data object'
- % OutputFile: ps Output', optional: 'name of postscript file to generate'
- %
- % 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',''})
- %
- % Khoros helpfile follows below:
- %
- % PROGRAM
- % gplot - Visualizes 2D Data
- %
- % DESCRIPTION
- %
- %
- %
- % EXAMPLES
- %
- % "SEE ALSO"
- %
- % RESTRICTIONS
- %
- % REFERENCES
- %
- % COPYRIGHT
- % Copyright (C) 1996-2003, Rainer Heintzmann, All rights reserved.
- %
- function varargout = kgplot(varargin)
- if nargin ==0
- Inputs={};arglist={'',''};
- elseif nargin ==1
- Inputs=varargin{1};arglist={'',''};
- elseif nargin ==2
- Inputs=varargin{1}; arglist=varargin{2};
- else error('Usage: [out1,..] = kgplot(Inputs,arglist).');
- end
- if size(arglist,2)~=2
- error('arglist must be of form {''ParameterTag1'',value1;''ParameterTag2'',value2}')
- end
- 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'};
- 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};
- 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};
- 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];
- was_set=istoggle * 0;
- 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'};
- % identify the input arrays and assign them to the arguments as stated by the user
- if ~iscell(Inputs)
- Inputs = {Inputs};
- end
- NumReqOutputs=1; nextinput=1; nextoutput=1;
- for ii=1:size(arglist,1)
- wasmatched=0;
- for jj=1:size(narglist,1)
- if strcmp(arglist{ii,1},narglist{jj,1}) % a given argument was matched to the possible arguments
- wasmatched = 1;
- was_set(jj) = 1;
- if strcmp(narglist{jj,2}, '__input')
- if (nextinput > length(Inputs))
- error(['Input ' narglist{jj,1} ' has no corresponding input!']);
- end
- narglist{jj,2} = 'OK_in';
- nextinput = nextinput + 1;
- elseif strcmp(narglist{jj,2}, '__output')
- if (nextoutput > nargout)
- error(['Output nr. ' narglist{jj,1} ' is not present in the assignment list of outputs !']);
- end
- if (isempty(arglist{ii,2}))
- narglist{jj,2} = 'OK_out';
- else
- narglist{jj,2} = arglist{ii,2};
- end
- nextoutput = nextoutput + 1;
- if (minval{jj} == 0)
- NumReqOutputs = NumReqOutputs - 1;
- end
- elseif isstr(arglist{ii,2})
- narglist{jj,2} = arglist{ii,2};
- else
- if strcmp(paramtype{jj}, 'Integer') & (round(arglist{ii,2}) ~= arglist{ii,2})
- error(['Argument ' arglist{ii,1} ' is of integer type but non-integer number ' arglist{ii,2} ' was supplied']);
- end
- if (minval{jj} ~= 0 | maxval{jj} ~= 0)
- if (minval{jj} == 1 & maxval{jj} == 1 & arglist{ii,2} < 0)
- error(['Argument ' arglist{ii,1} ' must be bigger or equal to zero!']);
- elseif (minval{jj} == -1 & maxval{jj} == -1 & arglist{ii,2} > 0)
- error(['Argument ' arglist{ii,1} ' must be smaller or equal to zero!']);
- elseif (minval{jj} == 2 & maxval{jj} == 2 & arglist{ii,2} <= 0)
- error(['Argument ' arglist{ii,1} ' must be bigger than zero!']);
- elseif (minval{jj} == -2 & maxval{jj} == -2 & arglist{ii,2} >= 0)
- error(['Argument ' arglist{ii,1} ' must be smaller than zero!']);
- elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} < minval{jj})
- error(['Argument ' arglist{ii,1} ' must be bigger than ' num2str(minval{jj})]);
- elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} > maxval{jj})
- error(['Argument ' arglist{ii,1} ' must be smaller than ' num2str(maxval{jj})]);
- end
- end
- end
- if ~strcmp(narglist{jj,2},'OK_out') & ~strcmp(narglist{jj,2},'OK_in')
- narglist{jj,2} = arglist{ii,2};
- end
- end
- end
- if (wasmatched == 0 & ~strcmp(arglist{ii,1},''))
- error(['Argument ' arglist{ii,1} ' is not a valid argument for this function']);
- end
- end
- % match the remaining inputs/outputs to the unused arguments and test for missing required inputs
- for jj=1:size(narglist,1)
- if strcmp(paramtype{jj}, 'Toggle')
- if (narglist{jj,2} ==0)
- narglist{jj,1} = '';
- end;
- narglist{jj,2} = '';
- end;
- if ~strcmp(narglist{jj,2},'__input') && ~strcmp(narglist{jj,2},'__output') && istoggle(jj) && ~ was_set(jj)
- narglist{jj,1} = '';
- narglist{jj,2} = '';
- end;
- if strcmp(narglist{jj,2}, '__input')
- if (minval{jj} == 0) % meaning this input is required
- if (nextinput > size(Inputs))
- error(['Required input ' narglist{jj,1} ' has no corresponding input in the list!']);
- else
- narglist{jj,2} = 'OK_in';
- nextinput = nextinput + 1;
- end
- else % this is an optional input
- if (nextinput <= length(Inputs))
- narglist{jj,2} = 'OK_in';
- nextinput = nextinput + 1;
- else
- narglist{jj,1} = '';
- narglist{jj,2} = '';
- end;
- end;
- else
- if strcmp(narglist{jj,2}, '__output')
- if (minval{jj} == 0) % this is a required output
- if (nextoutput > nargout & nargout > 1)
- error(['Required output ' narglist{jj,1} ' is not stated in the assignment list!']);
- else
- narglist{jj,2} = 'OK_out';
- nextoutput = nextoutput + 1;
- NumReqOutputs = NumReqOutputs-1;
- end
- else % this is an optional output
- if (nargout - nextoutput >= NumReqOutputs)
- narglist{jj,2} = 'OK_out';
- nextoutput = nextoutput + 1;
- else
- narglist{jj,1} = '';
- narglist{jj,2} = '';
- end;
- end
- end
- end
- end
- if nargout
- varargout = cell(1,nargout);
- else
- varargout = cell(1,1);
- end
- global KhorosRoot
- if exist('KhorosRoot') && ~isempty(KhorosRoot)
- w=['"' KhorosRoot];
- else
- if ispc
- w='"C:\Program Files\dip\khorosBin\';
- else
- [s,w] = system('which cantata');
- w=['"' w(1:end-8)];
- end
- end
- [varargout{:}]=callKhoros([w 'gplot" -k'],Inputs,narglist);