annotate toolboxes/MIRtoolbox1.3.2/somtoolbox/vis_planeGetArgs.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 function [nargin_,varargout]=vis_planeGetArgs(varargin)
wolffd@0 2
wolffd@0 3 % VIS_PLANEGETARGS Subfunction for som_*plane: extracts topolopy
wolffd@0 4 % information from the first arguments.
wolffd@0 5 %
wolffd@0 6 % [nargin,varargout]=vis_planeGetArgs(varargin)
wolffd@0 7 %
wolffd@0 8 % Input and output arguments:
wolffd@0 9 % varargin (varies) arguments given to som_*plane function
wolffd@0 10 % nargin_ (scalar) number of arguments that nargchk of som_*plane "should see"
wolffd@0 11 % +number_of_varargins if varargin{1} is not map/topol struct
wolffd@0 12 % +number_of_varargins+1 if varargin{2} is a map/topol struct
wolffd@0 13 % varargout (varies) the arguments that som_*plane "should see"
wolffd@0 14 %
wolffd@0 15 % Basically, this function allows topology information to be given
wolffd@0 16 % in various ways: either as a map/topology struct, or as a argument pair:
wolffd@0 17 % lattice, msize. The topology is always converted into the (lattice, msize)
wolffd@0 18 % argument pair.
wolffd@0 19 % - if first input argument (varargin{1}) is a map or topol struct
wolffd@0 20 % the function extracts lattice and msize fields to two first
wolffd@0 21 % output variables after 'nargin_'.
wolffd@0 22 % - otherwise it copies the input arguments to the output arguments
wolffd@0 23 % after 'nargin_'.
wolffd@0 24 % If there are too many inputs (as compared to number of outputs), the
wolffd@0 25 % last ones are ignored. If too few, they are replaced by empty values
wolffd@0 26 % in outputs.
wolffd@0 27 %
wolffd@0 28 % Example of usage:
wolffd@0 29 % function definition: h = som_cplane(varargin)
wolffd@0 30 % first code line: [nargin,lattice,msize,color,size,pos]=vis_planeGetArgs(varargin);
wolffd@0 31 %
wolffd@0 32 % See also SOM_CPLANE, SOM_BARPLANE, SOM_PLOTPLANE, SOM_PIEPLANE.
wolffd@0 33
wolffd@0 34 % Copyright (c) 2000 by the SOM toolbox programming team.
wolffd@0 35 % http://www.cis.hut.fi/projects/somtoolbox/
wolffd@0 36
wolffd@0 37 % Version 2.0beta Johan 240300
wolffd@0 38
wolffd@0 39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
wolffd@0 40
wolffd@0 41 nout=nargout-1;
wolffd@0 42
wolffd@0 43 % Set first all varargins to contain empty (==default values in som_*plane)
wolffd@0 44
wolffd@0 45 for i=1:nout, varargout{i}=[]; end
wolffd@0 46
wolffd@0 47 nargin_ = nargin;
wolffd@0 48 % Struct: might be map or topol
wolffd@0 49
wolffd@0 50 if isstruct(varargin{1}),
wolffd@0 51
wolffd@0 52 % Get topol from topol field
wolffd@0 53 if isfield(varargin{1},'topol'), topol=varargin{1}.topol;
wolffd@0 54 else topol=varargin{1}; % assume that this is topol struct
wolffd@0 55 end
wolffd@0 56
wolffd@0 57 if ~isstruct(topol),
wolffd@0 58 % topol not a struct !?
wolffd@0 59 warning('Field ''topol'' is not a struct.');
wolffd@0 60 varargout{1}=varargin{1};
wolffd@0 61 varargoutC=2;
wolffd@0 62 nargin_ = nargin;
wolffd@0 63 elseif ~isfield(topol,'msize') | ~isfield(topol,'lattice'),
wolffd@0 64 % Field missing?!
wolffd@0 65 warning('Invalid topology struct.');
wolffd@0 66 varargout{1}=topol;
wolffd@0 67 varargoutC=2;
wolffd@0 68 nargin_ = nargin;
wolffd@0 69 else
wolffd@0 70 varargout{1}=topol.lattice;
wolffd@0 71 varargout{2}=topol.msize;
wolffd@0 72 % increment input arg. counter
wolffd@0 73 varargoutC=3;
wolffd@0 74 nargin_ = nargin+1;
wolffd@0 75 end
wolffd@0 76
wolffd@0 77 elseif iscell(varargin{1}),
wolffd@0 78
wolffd@0 79 c = varargin{1};
wolffd@0 80 lattice = 'hexa'; shape = 'sheet'; msize = [1 1];
wolffd@0 81 for i=1:length(c),
wolffd@0 82 if ischar(c{i}),
wolffd@0 83 switch c{i},
wolffd@0 84 case {'hexa','hexaU','rect','rectU'}, lattice = c{i};
wolffd@0 85 case {'sheet','cyl','toroid'}, shape = c{i};
wolffd@0 86 end
wolffd@0 87 else
wolffd@0 88 msize = c{i};
wolffd@0 89 end
wolffd@0 90 end
wolffd@0 91 varargout{1} = lattice;
wolffd@0 92 varargout{2} = msize;
wolffd@0 93 varargoutC=3;
wolffd@0 94 nargin_ = nargin+1;
wolffd@0 95
wolffd@0 96 else
wolffd@0 97
wolffd@0 98 % should be a lattice (string)
wolffd@0 99 varargout{1}=varargin{1};
wolffd@0 100 varargoutC=2;
wolffd@0 101 nargin_=nargin;
wolffd@0 102
wolffd@0 103 end
wolffd@0 104
wolffd@0 105 for i=2:nargin, varargout{varargoutC+i-2}=varargin{i}; end
wolffd@0 106
wolffd@0 107 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%