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

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