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

📄 xoffset.m

📁 JLAB is a set of Matlab functions I have written or co-written over the past fifteen years for the p
💻 M
字号:
function[]=xoffset(i1,i2)%XOFFSET  Offsets lines in the x-direction after plotting.%	    	    	    %   XOFFSET allows data to be manipulated after it has been plotted,%   by operating on the data stored in the figure itself.  This is%   intended to be used only with 2-D line plots (not symbol plots,%   contour plots, etc.). XOFFSET also allow multiple axes to be%   manipulated simultaneously.%%   XOFFSET offsets all lines in the current axes a specified amount.%		%   XOFFSET(N) or XOFFSET N, where N is a *real* number, offsets each%   column of the X-data by an amount N from the previous column.  N%   must be a number, not a variable whose value is a number.%%   XOFFSET(N) or XOFFSET N, where N is an *imaginary* number, offsets%   each column of the X-data by an amount imag(N)*DX from the%   previous column, where DX is the X-axis length of the original%   (i.e. unoffset) plot.%%   XOFFSET(M,N) or XOFFSET M N, applies the same offsets to each of%   M groups of lines, i.e. for complex-valued data Z use UVPLOT(Z) %   followed by XOFFSET 2 N.%%   XOFFSET with no arguments returns the data to its original%   (unoffset) orientation [as do XOFFSET(0) and XOFFSET(0i)].%   %   XOFFSET LOCK and XOFFSET UNLOCK lock and unlock all Y-data in the%   current figure. When LOCK is on, calls to XOFFSET are applied to%   each subplot individually.%%   See also YOFFSET, LINERING, LINESTYLE%   __________________________________________________________________%   This is part of JLAB --- type 'help jlab' for more information%   (C) 2000, 2004 J.M. Lilly --- type 'help jlab_license' for details  if strcmp(i1,'--t')    returnendif nargin==1;  N=10000;  %Very large number of linesendif nargin==2  N=i1;  i1=i2;  if ischar(N)    N=str2num(N);  end endbcontinue=1;if nargin>0   if ischar(i1)      if isempty(str2num(i1))           i1=deblank(i1);           i1=fliplr(deblank(fliplr(i1)));	           if strcmp(i1,'lock')                if isappdata(gca,'lastxoffset')                    lastoff=getappdata(gca,'lastxoffset');                    setappdata(gcf,'xoffsetlock',1)                    xoffsetloop(0,N);                    xoffsetloop(lastoff,N);                 else                    setappdata(gcf,'xoffsetlock',1)                end		                 bcontinue=0;            end            if strcmp(i1,'unlock')                setappdata(gcf,'xoffsetlock',0)                bcontinue=0;            end      end   endendif bcontinue	   if nargin>0      delta=i1;   else       delta=0;   end   h=linehandles;   if plotmodified(h)   %If the plot has been changed, the old "lastxoffset" may no   %longer be correct.  If so, we set it to zero       setappdata(gca,'lastxoffset',0)		    end   xoffsetloop(delta,N);endfunction[]=xoffsetloop(delta,N)h=gca;if isappdata(gcf,'xoffsetlock')   if getappdata(gcf,'xoffsetlock')      h=axeshandles(gcf);	   end endfor i=1:length(h)    axes(h(i))    if isappdata(gca,'lastxoffset')       lastdelta=getappdata(gca,'lastxoffset');       xoffsetapply(-1*lastdelta,N);       setappdata(gca,'lastxoffset',0)    end    xoffsetapply(delta,N);endaxes(h(1))function[]=xoffsetapply(delta,N)h=linehandles;if ischar(delta),delta=str2num(delta);,endxx=get(h,{'xdata'});if length(delta)==1 && ~isreal(delta)   ax=axis;   dx=ax(2)-ax(1);   delta=dx.*imag(delta)/100;endif length(delta)==1   for i=1:length(xx)       xx{i}=xx{i}+delta*(mod(i-1,round(length(xx)/N)));   endelseif length(delta)==length(h)   for i=1:length(xx)       xx{i}=xx{i}+delta(i);   endelse   error(['Number of line handles does not equal offset array length'])endset(h,{'xdata'},xx);setappdata(gca,'lastxoffset',delta)		setappdata(gca,'lasthandles',h)		function[b]=plotmodified(h)b=0;  if isappdata(gca,'lasthandles')  b=1;  h2=getappdata(gca,'lasthandles');  if length(h2)==length(h)      if all(h2==h)          b=0;      end  endend  

⌨️ 快捷键说明

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