function varargout = TEmodes(m,p,varargin); %nu_mp = TEMODES(m,p) with no options returns the Bessel % root nu_mp for the given cylindrical Tranverse Electric % mode indicies, 'm' and 'p', where 'm' is the azimuthal % variation and 'p' is the radial variation (axial % variations are assumed to be unity). Both 'm' and 'p' % must be integers. A null [] is returned if a mode was % not found in the table. % %nu_mp = TEMODES(m,p, 'OPTIONS', OPTION_ARG) performs functions % defined by the OPTIONS string: % % OPTIONS: OPTION_ARG: Function: % 'neighbors' an integer N Returns a vector of the closest 2N % Bessel roots to the {mp} combination. % % 'family' an integer N Returns a vector of the closest 2N+1 % roots including the central root. % % If the limits of the table have been reached, the nu_mp vector % size decreases accordingly. % %[nu,mp] = TEMODES( ... ) returns roots in 'nu', and returns a % matrix 'mp' consisting of the 'm' root(s) in the first column % and the corresponding 'p' root(s) in the second column. % %[nu,m,p] = TEMODES( ... ) returns roots in 'nu', a column vector of % m-index/-ices in 'm' and a column vector of p-index/-ices in 'p'. % % %------------------------------- % Example: % temodes(0,4,'family',2) % % Returns: % 12.9324 % 13.1704 % 13.3237 % 13.8789 % 13.9872 %------------------------------- % % NOTE: requires the 'nu_TE.txt' data file, which stores root values. % % Last edit by Colin Joye, 8/19/03T % load TE roots table V = load('nu_TE.txt'); % find the locations of the roots in the table: M = find(V(:,1)==m); P = find(V(:,2)==p); if( isempty(M) | isempty(P) ), nu_mp = []; disp(['Error: TE_{' int2str(m) ',' int2str(p) '} mode not found.']); break; end % make matrices for comparison Sm = ones(length(P),1)*M'; Sp = P*ones(1,length(M)); % find location where m and p coincide loc = Sm( ind2sub( size(Sm),find( Sm==Sp ) ) ); % check for input arguments if nargin > 3, N = []; % search for 'neighbors' option n = find( strcmp( 'neighbors',varargin ) == 1); if ~isempty(n) N = varargin{n+1}; % create vector of neighboring root locations. loc = [loc-N:(loc-1) (loc+1):loc+N]; end % search for 'family' option n = find( strcmp( 'family',varargin ) == 1); if ~isempty(n) N = varargin{n+1}; % create vector of neighboring root locations. loc = [loc-N:loc+N]; end if isempty(N), disp(['Error, unknown options found']); break; end max = size(V,1); % make sure we stay within index limits loc = loc( find(loc > 0 & loc < max) ); nu_mp = V(loc,3); else % no varargs were given, just return one root. nu_mp = V(loc,3); end % return the right number of outputs switch(nargout) case {0,1} varargout = {nu_mp}; case {2} varargout = {nu_mp,[V(loc,1) V(loc,2)]}; case {3} varargout = {nu_mp,V(loc,1),V(loc,2)}; otherwise disp('Error in TEMODES.m, wrong number of outputs'); break; end % --- END TEmodes.m ----------------