www.pudn.com > P-zernike.zip > paraget.m, change:2006-05-23,size:1335b


function	[pval,option]	= paraget(pname,option,defval) 
if nargin>0 
FRAC	= 0.33; 
plen	= length(pname); 
if isempty(option)&nargin==3 
	pval	= defval; 
	if ischar(pval) 
		option	= [pname ' ' pval];		 
	else 
		option	= [pname ' ' num2str(pval)];	 
	end 
	return; 
else 
	if nargin<3 
		defval	= 0; 
	end 
	w	= findstr(pname,option);	 
 
	if ~isempty(w) 
		s	= findstr(' ',option);		 
		thes	= s(find(s>w)); 
		p1	= killadj(thes,1); 
		p2	= killadj(thes,0); 
		if length(p1)==1 
			p2(2)	= length(option)+1; 
		end 
		pstr	= option(p1(1)+1:p2(2)-1); 
		plen	= p2(2)-p1(1)-1; 
 
		if sum(pstr>57)/plen<FRAC 
			pval	= str2num(pstr);	 
		else 
			pval	= pstr;			 
		end 
	else						 
		pval	= defval; 
		if ischar(pval) 
			option	= [option ' ' pname ' ' pval];		 
		else 
			option	= [option ' ' pname ' ' num2str(pval)];	 
		end 
		return; 
	end 
end 
else 
end 
 
function	[outnum]= killadj(innum,keep) 
 
if nargin<2 
	keep = 0; 
end 
 
mask	= ones(size(innum)); 
nin	= length(innum); 
 
if keep==0 
%	vdiff			= innum-[innum(1) innum(1:nin-1)]; 
	vdiff			= [0 diff(innum)]; 
 
	whereconsecutive	= find(vdiff==1); 
else 
%	vdiff			= [innum(2:nin) innum(nin)]-innum; 
	vdiff			= [diff(innum) 0]; 
	whereconsecutive	= find(vdiff==1); 
end 
 
mask(whereconsecutive)	= zeros(size(whereconsecutive)); 
 
outnum			= innum(mask~=0); 
return;