Daniel@0: function [nargin_,varargout]=vis_planeGetArgs(varargin) Daniel@0: Daniel@0: % VIS_PLANEGETARGS Subfunction for som_*plane: extracts topolopy Daniel@0: % information from the first arguments. Daniel@0: % Daniel@0: % [nargin,varargout]=vis_planeGetArgs(varargin) Daniel@0: % Daniel@0: % Input and output arguments: Daniel@0: % varargin (varies) arguments given to som_*plane function Daniel@0: % nargin_ (scalar) number of arguments that nargchk of som_*plane "should see" Daniel@0: % +number_of_varargins if varargin{1} is not map/topol struct Daniel@0: % +number_of_varargins+1 if varargin{2} is a map/topol struct Daniel@0: % varargout (varies) the arguments that som_*plane "should see" Daniel@0: % Daniel@0: % Basically, this function allows topology information to be given Daniel@0: % in various ways: either as a map/topology struct, or as a argument pair: Daniel@0: % lattice, msize. The topology is always converted into the (lattice, msize) Daniel@0: % argument pair. Daniel@0: % - if first input argument (varargin{1}) is a map or topol struct Daniel@0: % the function extracts lattice and msize fields to two first Daniel@0: % output variables after 'nargin_'. Daniel@0: % - otherwise it copies the input arguments to the output arguments Daniel@0: % after 'nargin_'. Daniel@0: % If there are too many inputs (as compared to number of outputs), the Daniel@0: % last ones are ignored. If too few, they are replaced by empty values Daniel@0: % in outputs. Daniel@0: % Daniel@0: % Example of usage: Daniel@0: % function definition: h = som_cplane(varargin) Daniel@0: % first code line: [nargin,lattice,msize,color,size,pos]=vis_planeGetArgs(varargin); Daniel@0: % Daniel@0: % See also SOM_CPLANE, SOM_BARPLANE, SOM_PLOTPLANE, SOM_PIEPLANE. Daniel@0: Daniel@0: % Copyright (c) 2000 by the SOM toolbox programming team. Daniel@0: % http://www.cis.hut.fi/projects/somtoolbox/ Daniel@0: Daniel@0: % Version 2.0beta Johan 240300 Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: nout=nargout-1; Daniel@0: Daniel@0: % Set first all varargins to contain empty (==default values in som_*plane) Daniel@0: Daniel@0: for i=1:nout, varargout{i}=[]; end Daniel@0: Daniel@0: nargin_ = nargin; Daniel@0: % Struct: might be map or topol Daniel@0: Daniel@0: if isstruct(varargin{1}), Daniel@0: Daniel@0: % Get topol from topol field Daniel@0: if isfield(varargin{1},'topol'), topol=varargin{1}.topol; Daniel@0: else topol=varargin{1}; % assume that this is topol struct Daniel@0: end Daniel@0: Daniel@0: if ~isstruct(topol), Daniel@0: % topol not a struct !? Daniel@0: warning('Field ''topol'' is not a struct.'); Daniel@0: varargout{1}=varargin{1}; Daniel@0: varargoutC=2; Daniel@0: nargin_ = nargin; Daniel@0: elseif ~isfield(topol,'msize') | ~isfield(topol,'lattice'), Daniel@0: % Field missing?! Daniel@0: warning('Invalid topology struct.'); Daniel@0: varargout{1}=topol; Daniel@0: varargoutC=2; Daniel@0: nargin_ = nargin; Daniel@0: else Daniel@0: varargout{1}=topol.lattice; Daniel@0: varargout{2}=topol.msize; Daniel@0: % increment input arg. counter Daniel@0: varargoutC=3; Daniel@0: nargin_ = nargin+1; Daniel@0: end Daniel@0: Daniel@0: elseif iscell(varargin{1}), Daniel@0: Daniel@0: c = varargin{1}; Daniel@0: lattice = 'hexa'; shape = 'sheet'; msize = [1 1]; Daniel@0: for i=1:length(c), Daniel@0: if ischar(c{i}), Daniel@0: switch c{i}, Daniel@0: case {'hexa','hexaU','rect','rectU'}, lattice = c{i}; Daniel@0: case {'sheet','cyl','toroid'}, shape = c{i}; Daniel@0: end Daniel@0: else Daniel@0: msize = c{i}; Daniel@0: end Daniel@0: end Daniel@0: varargout{1} = lattice; Daniel@0: varargout{2} = msize; Daniel@0: varargoutC=3; Daniel@0: nargin_ = nargin+1; Daniel@0: Daniel@0: else Daniel@0: Daniel@0: % should be a lattice (string) Daniel@0: varargout{1}=varargin{1}; Daniel@0: varargoutC=2; Daniel@0: nargin_=nargin; Daniel@0: Daniel@0: end Daniel@0: Daniel@0: for i=2:nargin, varargout{varargoutC+i-2}=varargin{i}; end Daniel@0: Daniel@0: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%