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

📄 arrow_mouse.m

📁 hi i have a huge collection are you interested
💻 M
字号:
function h = arrow_mouse( aspect, tail, head );% function h = arrow_mouse( aspect, tail, head );%% Use mouse to place an arrow on your linear, loglog, or semilog plot.% Optional args:   aspect    >1 = wider    <1 = narrower%                  tail = [x y]  %                  head = [x y]%% Examples:  h = arrow_mouse;                      % draw normal arrow with mouse%            h = arrow_mouse( .75, [0 1], [5 9] ); % narrow arrow at specific place%            h = arrow_mouse( 1.5 );               % draw wide arrow with mouse%%            h is the graphics handle for the arrow% get the endpointsif nargin~=3,  % get coords  sprintf('click on TAIL then HEAD of arrow')  [x,y] = ginput(2);  sprintf('tail=[%e %e];', x(1),  y(1))  sprintf('head=[%e %e];', x(2),  y(2))else x(1)=tail(1); y(1)=tail(2); x(2)=head(1); y(2)=head(2);end% build arrow prototype (from [0,0] to [1,0])if nargin==0 | nargin==2,  aspect=1;endd=.075;s=1.2*pi/4; % 1/2 angle at the point of the arrowq=.8;p=max(.27,d/sin(s/2));q=max(q,1-p*cos(s/2));ax=[0,0,q,1-p*cos(s/2),1,1-p*cos(s/2),q,0];ay=[-d/2,d/2,d/2,p*sin(s/2),0,-p*sin(s/2),-d/2,-d/2]*aspect;% move endpoints to linear scale% and find aspect ratio of plotys = get(gca,'yscale');ylim = get(gca,'ylim');if ys(1:3)=='log',  yy = log10(y);  ylim = log10(ylim);else  yy = y;enddy = diff(yy);xs = get(gca,'xscale');xlim = get(gca,'xlim');if xs(1:3)=='log',  xx = log10(x);  xlim = log10(xlim);else  xx = x;enddx = diff(xx);%correct prototype for lengthay=ay/sqrt(dy*dy+dx*dx);% adjust prototype to square aspectaspect = diff(ylim)/diff(xlim);dy = dy/aspect;% scale and shift prototyper = dx + i*dy;              % complex representation of arrow at originm=abs(r);                   % lengtha=angle(r);                 % angleT = [cos(a),sin(a);-sin(a),cos(a)]; % rotation matrixar = [ax(:) ay(:)]*T;       % rotate prototypear(:,2)=ar(:,2)*aspect;     % correct destination aspectnxy = ones(8,1)*[xx(1) yy(1)] + m*ar; %shift to tail point, scale to final size% move back to log or semilog co-ordinates if necessaryif xs(1:3)=='log', x = 10.^nxy(:,1);else x = nxy(:,1);endif ys(1:3)=='log', y = 10.^nxy(:,2);else y = nxy(:,2);end% draw the arrow, black with narrow white edgeif aspect<1,  h=patch(x,y,'w','linewidth',0.2,'edgecolor','w');else  h=patch(x,y,'k','linewidth',0.2,'edgecolor','w');end

⌨️ 快捷键说明

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