⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 slicetool.m

📁 基于matlab的反演程序,用于地球物理勘探中射线追踪及偏移成像程序.
💻 M
📖 第 1 页 / 共 5 页
字号:
		hpolystore hscale hslopetools hautopro halgebra hpromote...		hdefineqn hscatter hshowfile hsaveas hup hdown...		hleft hright hpolydisp hautoident haltlabels haltx...		halty hpolyeval hptsize hhardcopy hnumcolors hpolygen...		hsmooth hdefinesm hderiv]);				% define the buttondown function		set(hfig,'windowbuttondownfcn',''); % because the initial action is plot, these										% are just dummy definitions		% define the buttonup function		set(hfig,'windowbuttonupfcn','');	% make a plot	slicetool('plot');		return;end	% plot the curvesif( strcmp(action,'plot') )	h=get(gcf,'userdata');	hdoit=h(1);	hflipx=h(3);	hflipy=h(4);	hhold=h(5);	hactions=h(6);	hxaxis=h(7);	hyaxis=h(8);	hmode=h(10);	hmsg=h(11);	htranstore=h(12);	hcmplxstore=h(13);	hgrid=h(14);	hcomplex=h(15);	hscale=h(20);	hscatter=h(26);	hautoident=h(34);	haltx=h(36);	halty=h(37);	hptsize=h(39);	hnumcolors=h(41);		actioninfo = get(hactions,'userdata');	hzoom = actioninfo(3);	hpolyfit=actioninfo(6);	hident= actioninfo(7);		% clear the axes userdata	set(gca,'userdata',[]);	% set the msg string to zip	set(hmsg,'string','');	% set some graphics flags	flag=get(hflipx,'checked');	xflip=0;	if( strcmp(flag,'on')) xflip=1; end		flag=get(hflipy,'checked');	yflip=0;	if( strcmp(flag,'on')) yflip=1; end		flag=get(hhold,'checked');	holdit=0;	if( strcmp(flag,'on')) holdit=1; end		flag=get(hgrid,'checked');	gridon=0;	if( strcmp(flag,'on')) gridon=1; end		% reset the axes	if( ~holdit ) cla reset; set(gca,'visible','off'); drawnow; end	% clear out the polyfit info	if( ~holdit ) 		polyid=get(hpolyfit,'userdata');		set(hpolyfit,'userdata',polyid(1));	end		%get the object	obj=get(hdoit,'userdata');		% get the x axis vectors		xinfo = get(hxaxis,'userdata');	xdisp=xinfo(3+xinfo(1):length(xinfo) );		% get the y axis vectors		yinfo = get(hyaxis,'userdata');	ydisp=yinfo(3+yinfo(1):length(yinfo) );		% make sure either xinfo or yinfo is of length 1	if( length(xdisp)~=1 & length(ydisp)~=1 )		msg=' The number of x displays or y displays must equal 1';		set(hmsg,'string',msg);		error(msg);	end		% make the x axis displays		xvectors = [];	nx=length(xdisp);	for k=1:nx	    x=objget(obj,xdisp(k) );		xvectors = [ xvectors x(:) ];	end		% make the y axis displays		yvectors = [];	ny=length(ydisp);	for k=1:ny	    y=objget(obj,ydisp(k) );		yvectors = [ yvectors y(:) ];	end	% check transform flag and do so if needed	flag=get(hmode,'userdata');	flag=flag(1);	if( flag == 2 ) %do a transform		% check the htranstore userdata to see if a transform already exists		dat=get(htranstore,'userdata');		if(length(dat)==0)			set(htranstore,'userdata',[xvectors yvectors]);			slicetool('transform');			dat=get(htranstore,'userdata');		end		xvectors = dat(:,1:nx);		yvectors = dat(:,nx+1:nx+ny);		end	% see if data is complex and needs processing	complexflag=0;	if( iscomplex(xvectors) | iscomplex(yvectors) )		complexflag=1; % set a flag for later use		%check hcmplxstore to see if it has already been done		dat =get(hcmplxstore,'userdata');		if( length(dat)==0)			set(hcmplxstore,'userdata',[xvectors yvectors]);			slicetool('cmplxfmt');			dat = get(hcmplxstore,'userdata');		end		xvectors=dat(:,1:nx);		yvectors=dat(:,nx+1:nx+ny);	end	% perform scaling if needed	flag = get(hscale,'checked');	if(strcmp(flag,'on')) % off means independent scaling is off so we				% scale everything into the range +/- 1		if( ~complexflag ) % only do this on real data			if( nx==1) % scale the y vectors				for k=1:ny					ilive=find(~isnan(yvectors(:,k)));					factor=max(abs(yvectors(ilive,k)));					term=min(abs(yvectors(ilive,k)));					yvectors(:,k)=(yvectors(:,k)-term)/(factor-term);				end			else				for k=1:nx					ilive=find(~isnan(xvectors(:,k)));					factor=max(abs(xvectors(ilive,k)));					term=min(abs(yvectors(ilive,k)));					xvectors(:,k)=(xvectors(:,k)-term)/(factor-term);				end			end		end	end		%generate some colors	nkol=get(hnumcolors,'userdata');	kolorset=zeros(nkol,3);	%kolorset(:,1)=((nkol:-1:1)/nkol)';%red 1-0 ramp	%kolorset(:,2)=((1:nkol)')/nkol;%green 0-1 ramp	%kolorset(:,3)=([2:2:nkol nkol-2:-2:0]')/nkol;%blue 0-1-0 ramp	if( 2*(floor(nkol/2))==nkol )		kolorset(:,1)=([nkol:-2:2 0:2:nkol-2]/nkol)';%red 1-0-1 ramp		kolorset(:,2)=([2:2:nkol nkol-2:-2:0]')/nkol;%green 0-1-0 ramp		kolorset(:,3)=((1:nkol)')/nkol;%blue 0-1 ramp	else		kolorset(:,1)=([nkol:-2:2 0:2:nkol-1]/nkol)';%red 1-0-1 ramp		kolorset(:,2)=([2:2:nkol nkol-1:-2:0]')/nkol;%green 0-1-0 ramp		kolorset(:,3)=((1:nkol)')/nkol;%blue 0-1 ramp	end		% for each curve, determine its unique color by indexing into the color	% set	if(nx==1)		kolors=zeros(ny,3);		for k=1:ny			index=rem(ydisp(k),nkol);			if(~index) index=nkol; end			kolors(k,:)=kolorset(index,:);		end	else		kolors=zeros(nx,3);		for k=1:nx			index=rem(xdisp(k),nkol);			if(~index) index=nkol; end			kolors(k,:)=kolorset(index,:);		end	end	%get the scatterplot flag	scatter=get(hscatter,'checked');	if(strcmp(scatter,'on'))		linestyle='.';	else		linestyle='-';	end	%get the markersize	ptsize=get(hptsize,'userdata');		% make a plot. This will depend on the complex data option	flag=get(hcomplex,'userdata');	flag=flag(1);		idinfo = get(hident,'userdata');	subplots=0;	if( ~complexflag )		subplot(1,1,1);		set(gca,'colororder',kolors,'visible','on');		% use line to get the handles		hcurves=line(xvectors,yvectors,'linestyle',linestyle,'markersize',ptsize); 		% set the id info. The basic idea here is that hident userdata 		% will provide the handles of the plotted curves and the handles		% of an optional text label naming the curve. If there are 2 subplots,		% then this is repeatedi in a second row.		% so if ndisp is the number of displayed curves,		% then the size of the user data is [1,2*ndisp+1]for 1 subplot and		% [2,2*ndisp+1] for 2 subplots.		set(hident,'userdata',[idinfo(1),hcurves',zeros(size(hcurves'))]);		set(actioninfo(3),'enable','on'); % enable zooming		set(actioninfo(4),'enable','on'); % enable unzooming		set(actioninfo(5),'enable','on'); % enable slopepicking		set(actioninfo(6),'enable','on'); % enable polyfitting		set(actioninfo(7),'enable','on'); % enable identifying		axis('auto'); %autoscale	elseif( flag < 4)		subplot(1,1,1)		set(gca,'colororder',kolors,'visible','on');		% use line to get the handles		hcurves=line(xvectors,yvectors,'linestyle',linestyle,'markersize',ptsize); 		set(hident,'userdata',[idinfo(1),hcurves',zeros(size(hcurves'))]);		set(actioninfo(3),'enable','on'); % enable zooming		set(actioninfo(4),'enable','on'); % enable unzooming		set(actioninfo(5),'enable','on'); % enable slopepicking		set(actioninfo(6),'enable','on'); % enable polyfitting		set(actioninfo(7),'enable','on'); % enable identifying		axis('auto'); %autoscale	elseif( flag > 3 & nx == 1)		subplots=1;		subplot(2,1,1);		set(gca,'colororder',kolors,'visible','on');		% use line to get the handles		hcurves=line(xvectors,real(yvectors),'linestyle',linestyle,'markersize',ptsize); 		idinfo=[idinfo(1) hcurves' zeros(size(hcurves'))];		set(hident,'userdata',idinfo);		axis('auto'); %autoscale		title1='Amplitude Spectra';		subplot(2,1,2);		set(gca,'colororder',kolors,'visible','on');		hcurves=line(xvectors,imag(yvectors),'linestyle',linestyle,'markersize',ptsize); 		idinfo=[idinfo;0 ,hcurves',zeros(size(hcurves'))];		set(hident,'userdata',idinfo);		axis('auto'); %autoscale		title2='Phase Spectra';		set(actioninfo(3),'enable','off'); % disable zooming		set(actioninfo(4),'enable','off'); % disable unzooming		set(actioninfo(5),'enable','off'); % disable slopepicking		set(actioninfo(6),'enable','off'); % disable polyfitting		set(actioninfo(7),'enable','off'); % disable identifying	elseif( flag > 3 & ny==1 & nx ~= 1)		subplots=1;		subplot(2,1,1);		set(gca,'colororder',kolors,'visible','on');        hcurves=line(real(xvectors),yvectors,'linestyle',linestyle,'markersize',ptsize);        idinfo=[idinfo(1) hcurves' zeros(size(hcurves'))];		set(hident,'userdata',idinfo);		axis('auto'); %autoscale		title1='Real Spectra';        subplot(2,1,2);        set(gca,'colororder',kolors,'visible','on');        hcurves=line(imag(xvectors),yvectors,'linestyle',linestyle,'markersize',ptsize);		idinfo=[idinfo;0 ,hcurves',zeros(size(hcurves'))];		set(hident,'userdata',idinfo);		axis('auto'); %autoscale		title2='Imaginary Spectra';		set(actioninfo(3),'enable','off'); % disable zooming		set(actioninfo(4),'enable','off'); % disable unzooming		set(actioninfo(5),'enable','off'); % disable slopepicking		set(actioninfo(6),'enable','off'); % disable polyfitting		set(actioninfo(7),'enable','off'); % disable identifying	end	if( ~subplots )		% set the plot directions and grid		xlabels=[]; ylabels=[];		if(xflip) set(gca,'xdir','reverse'); end		if(yflip) set(gca,'ydir','reverse'); end		if(gridon) set(gca,'xgrid','on','ygrid','on'); end		if(holdit) hold on;			else hold off;		% check for alternate x axis tick labels		if(nx==1)			flag=get(haltx,'checked');			if( strcmp(flag,'on') )				xlabelname=get(haltx,'userdata');				if( xlabelname~=0 )					xlabelvalues=objget(obj,xlabelname);					xtick=get(gca,'xtick');					xlabels=[];					for k=1:length(xtick)						ind=near(xvectors,xtick(k));						xlabels=strmat(xlabels,num2str(xlabelvalues(ind)));					end					set(gca,'xticklabel',xlabels);				end			end		end		% check for alternate y axis tick labels		if(ny==1)			flag=get(halty,'checked');			if( strcmp(flag,'on') )				ylabelname=get(halty,'userdata');				if(ylabelname ~= 0)					ylabelvalues=objget(obj,ylabelname);					ytick=get(gca,'ytick');					ylabels=[];					for k=1:length(ytick)						ind=near(yvectors,ytick(k));						ylabels=strmat(ylabels,num2str(ylabelvalues(ind)));					end					set(gca,'yticklabel',ylabels);				end			end		end	end  	% add a title	title(objget(obj,'name'));	% label the x axis	if( length(xdisp)>1 )		xlabel('Multiple Curves');	else		if( isempty(xlabels) )			xlabel(objget(obj,'dataname',xdisp));		else			if(~isstr(xlabelname))				xlabelname=objget(obj,'dataname',xlabelname);			end			str=[objget(obj,'dataname',xdisp),' (labeled by ' xlabelname ')'];			xlabel(str);		end	end	% label the y axis	if( length(ydisp)>1 )		ylabel('Multiple Curves');	else		if( isempty(ylabels) )			ylabel(objget(obj,'dataname',ydisp));		else			if(~isstr(ylabelname))				ylabelname=objget(obj,'dataname',ylabelname);			end			str=[objget(obj,'dataname',ydisp),' (labeled by ' ylabelname ')'];			ylabel(str);		end	end   else	% add a title	subplot(2,1,1)	% set the plot directions and grid	if(xflip) set(gca,'xdir','reverse'); end	if(yflip) set(gca,'ydir','reverse'); end	if(gridon) set(gca,'xgrid','on','ygrid','on'); end	if(holdit) hold on;	else hold off;	end	title(title1);	% label the x axis	if( length(xdisp)>1 )		xlabel('Multiple Curves');	else		xlabel(objget(obj,'dataname',xdisp));	end	% label the y axis	if( length(ydisp)>1 )		ylabel('Multiple Curves');	else		ylabel(objget(obj,'dataname',ydisp));	end	% add a title	subplot(2,1,2)	% set the plot directions and grid	if(xflip) set(gca,'xdir','reverse'); end	if(yflip) set(gca,'ydir','reverse'); end	if(gridon) set(gca,'xgrid','on','ygrid','on'); end	if(holdit) hold on;	else hold off;	end	title(title2);	% label the x axis	if( length(xdisp)>1 )		xlabel('Multiple Curves');

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -