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