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

📄 mmzoom.m

📁 精通Matlab综合辅导与指南-源程序随书带的光盘
💻 M
字号:
function mmzoom(arg)%MMZOOM Simple 2-D Zoom-In Function Using RBBOX.% MMZOOM zooms in on a plot based on the size of a% rubberband box drawn by the user with the mouse.% MMZOOM x     zooms the x-axis only.% MMZOOM y     zooms the y-axis only.% MMZOOM reset or% MMZOOM out   restores original axis limits.%% Striking a key on the keyboard aborts the command.% MMZOOM becomes inactive after zoom is complete or aborted.% D.C. Hanselman, University of Maine, Orono, ME, 04469% 3/29/95% Copyright (c) 1996 by Prentice-Hall, Inc.global MMZOOM_DEFAXISLIMSglobal MMZOOM_AXESHf=mmgcf;if isempty(Hf), error('No Figure Available.'), endif nargin==0,arg=' ';endarg=arg(1);if (arg=='r'|arg=='o') &~isempty(MMZOOM_DEFAXISLIMS)  % reset request	set(MMZOOM_AXES,'Xlim',MMZOOM_DEFAXISLIMS(1:2),...					'Ylim',MMZOOM_DEFAXISLIMS(3:4))	MMZOOM_DEFAXISLIMS=[];MMZOOM_AXES=[];	returnelseif (arg=='r'|arg=='o') % already reset	returnendif length(findobj(0,'Type','figure'))==1	figure(Hf) % bring only figure forwardendkey=waitforbuttonpress; % user chooses a figure and axes to zoomif key  % key on keyboard pressed	mmzoom('reset')  % clean stuff up with a recursive callelse    % figure selected	if any(get(gca,'View')~=[0 90]),error('Plot must be 2-D.'),end	if isempty(MMZOOM_DEFAXISLIMS)  % store limits for future reset		MMZOOM_DEFAXISLIMS=axis;		MMZOOM_AXES=gca;	end		cp=get(gca,'CurrentPoint');  	% get first point	cfp=get(gcf,'CurrentPoint'); 	% get pointer w.r.t. figure	rbbox([cfp 0 0],cfp)			% drag rubberband box at cfp	cp=[cp;get(gca,'CurrentPoint')];% add second point		% convert points to useful axis limits	lims=[min(cp(:,1)) max(cp(:,1)) min(cp(:,2)) max(cp(:,2))];	alims=axis;	dlims=max(diff(alims)/20,diff(lims)); % max zoom is 20X	lims=[lims(1) lims(1)+dlims(1) lims(3) lims(3)+dlims(3)];		lims=[	max(lims(1),alims(1)) min(lims(2),alims(2)) ...			max(lims(3),alims(3)) min(lims(4),alims(4))]; % no zoom out				if arg=='x',		set(gca,'Xlim',lims(1:2))	elseif arg=='y',	set(gca,'Ylim',lims(3:4))	else				set(gca,'Xlim',lims(1:2),'Ylim',lims(3:4))	endend

⌨️ 快捷键说明

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